• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

To create Vertical line by VBA Macro where ever i click mouse

Manan

New Member
Hi Masters ,

I have a strange requirement. I have a combined chart Line Chart. i.e. i have grouped two line charts. Now i want to create a vertical line with the help of mouse click. I can do it with help of images but it is too tedious to draw and also they are not accurate . Can you please help me out with this.

Thanks,
Manan.
 
Hi Masters,

I have got the solution. Below is the code. But any improvement is hearlty appreciated.
Code:
Sub Line()
ActiveSheet.Shapes.AddLine(350, 350, 350, 100#).Select
Selection.ShapeRange.Line.EndArrowheadStyle = msoArrowheadTriangle
Selection.ShapeRange.Line.Weight = 1.5
Selection.ShapeRange.Line.DashStyle = msoLineSolid
End Sub
 
If you post the file, there may be a much better way to do what you want

The problem with your solution is that if anybody changes the column or chart widths it will be in the wrong spot
 
If you wanted to add the line to a Chart, If the chart was a ChartSheet instead of on a Worksheet, You could use the Mouse Down and Mouse Up events, to click where you wanted the line
 
Hi Sir,

Thanks for reply . I have the chart on worksheet. Can i have mouse click event that where ever i click the mouse the macro creates the vertical line their. I know it may be tricky but any help sir ??

Thanks a lot in advance for your valuable time.

Manan.

If you wanted to add the line to a Chart, If the chart was a ChartSheet instead of on a Worksheet, You could use the Mouse Down and Mouse Up events, to click where you wanted the line
 
Back
Top