大概能满足吧: Sub Macro2() While ActiveSheet.Shapes.Count > 0 ActiveSheet.Shapes(1).Delete Wend Dim startdate As Date, enddate As Date Dim l As Single, t As Single, r As Single For i = 5 To 15 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).Left + ((startdate - #10/1/2006#) / 30) * Cells(i, 4).Width r = Cells(i, 4).Left + ((enddate - #10/1/2006#) / 30) * Cells(i, 4).Width ActiveSheet.Shapes.AddLine l, t, r, t Next End Sub |