How to click on a point in graph and use this point(x, y) value in further calculation automatically

New Contributor

Hi,

I have a situation where I have to give input from graph. I will have to click on a point in graph and this value will be used in further calculation.  How can I apply this in excel?

Thanks in advance

1 Reply

@nyeas001 

The Chart object has several events.  MouseUp ( or MouseDown) would be the one for you to use.

The syntax is

Private Sub Chart_MouseDown(ByVal Button As Long, ByVal Shift As Long, ByVal x As Long, ByVal y As Long)

End Sub

See Chart.MouseUp event (Excel) for a discussion of the arguments.

For charts on a separate chart sheet, the use is straightforward: right-click the chart sheet tab, select 'View Code' from the context menu and start creating your event procedure.

For charts embedded on a worksheet, it is more complicated: you have to create a class module to handle the events. See for example Embedded Chart Events Using VBA in Excel.

More info: Chart Events in Microsoft Excel.