第1个回答 2012-04-23
ActiveSheet.DrawingObjects.Delete
Dim startdate As Date, enddate As Date
Dim l As Single, t As Single, r As Single, sh As Shape
For i = 5 To 24
If Cells(i, 3) > "" Then
startdate = CDate(Replace(Split(Cells(i, 3), "-")(0), ".", "-"))
enddate = CDate(Replace(Split(Cells(i, 3), "-")(1), ".", "-"))
t = (Cells(i, 1).Top + Cells(i + 1, 1).Top) / 2
l = Cells(i, 4 + DateDiff("m", #9/1/2008#, startdate)).Left + Day(startdate) * Cells(i, 4).Width / Day(DateSerial(Year(startdate), Month(startdate) + 1, 0))
r = Cells(i, 4 + DateDiff("m", #9/1/2008#, enddate)).Left + Day(enddate) * Cells(i, 4).Width / Day(DateSerial(Year(enddate), Month(enddate) + 1, 0))
Set sh = ActiveSheet.Shapes.AddLine(l, t, r, t)
sh.Line.Weight = 1.8
sh.Line.ForeColor.RGB = Int(Rnd * &HFFFFFF)
End If
Next
你看看,是否可以学会划线呢