I know you can draw lines on a worksheet (via the drawing tools), using macros like this:
Private Sub CommandButton1_Click()
ActiveSheet.Shapes.AddLine(168#, 12.75, 168#, 102#).Select
End Sub
But the position references for the AddLine method are point coordinates.
Is it possible to draw continous,vertical lines down through the center of cells on a worksheet using the cell numbers as references?
(I have tried using the Border methods, but these only allow you to draw lines on the edge of cells.)
Try
Sub Test() Call DrawLine("B1", "B10") End Sub Sub DrawLine(Cell1, Cell2) ActiveSheet.Shapes.AddLine(Range(Cell1).Left + (Range(Cell1).Width / 2), Range(Cell1).Top, Range(Cell2).Left + (Range(Cell2).Width / 2), Range(Cell2).Top + Range(Cell2).Height).Select End Sub
Martin
Eighty Twenty Spreadsheet Automation http://homepage.ntlworld.com/martin.rice1/ for all your Excel customisation and consulting needs.
If my solution has saved you time and/or money, please consider donating to Cancer Research UK.
Many thanks, Martin.
That's excellent!
![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks