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

%3CLINGO-SUB%20id%3D%22lingo-sub-2365984%22%20slang%3D%22en-US%22%3EHow%20to%20click%20on%20a%20point%20in%20graph%20and%20use%20this%20point(x%2C%20y)%20value%20in%20further%20calculation%20automatically%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2365984%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%20have%20a%20situation%20where%20I%20have%20to%20give%20input%20from%20graph.%20I%20will%20have%20to%20click%20on%20a%20point%20in%20graph%20and%20this%20value%20will%20be%20used%20in%20further%20calculation.%26nbsp%3B%20How%20can%20I%20apply%20this%20in%20excel%3F%3C%2FP%3E%3CP%3EThanks%20in%20advance%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2365984%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ECharting%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2366123%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20click%20on%20a%20point%20in%20graph%20and%20use%20this%20point(x%2C%20y)%20value%20in%20further%20calculation%20automatic%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2366123%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1057183%22%20target%3D%22_blank%22%3E%40nyeas001%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20Chart%20object%20has%20several%20events.%26nbsp%3B%20MouseUp%20(%20or%20MouseDown)%20would%20be%20the%20one%20for%20you%20to%20use.%3C%2FP%3E%0A%3CP%3EThe%20syntax%20is%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-visual%22%3E%3CCODE%3EPrivate%20Sub%20Chart_MouseDown(ByVal%20Button%20As%20Long%2C%20ByVal%20Shift%20As%20Long%2C%20ByVal%20x%20As%20Long%2C%20ByVal%20y%20As%20Long)%0A%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ESee%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foffice%2Fvba%2Fapi%2Fexcel.chart.mouseup%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EChart.MouseUp%20event%20(Excel)%3C%2FA%3E%20for%20a%20discussion%20of%20the%20arguments.%3C%2FP%3E%0A%3CP%3EFor%20charts%20on%20a%20separate%20chart%20sheet%2C%20the%20use%20is%20straightforward%3A%20right-click%20the%20chart%20sheet%20tab%2C%20select%20'View%20Code'%20from%20the%20context%20menu%20and%20start%20creating%20your%20event%20procedure.%3C%2FP%3E%0A%3CP%3EFor%20charts%20embedded%20on%20a%20worksheet%2C%20it%20is%20more%20complicated%3A%20you%20have%20to%20create%20a%20class%20module%20to%20handle%20the%20events.%20See%20for%20example%20%3CA%20href%3D%22https%3A%2F%2Fwww.exceltip.com%2Fevents-in-vba%2Fchart-object-events-using-vba-in-microsoft-excel.html%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EEmbedded%20Chart%20Events%20Using%20VBA%20in%20Excel%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3EMore%20info%3A%20%3CA%20href%3D%22https%3A%2F%2Fpeltiertech.com%2Fchart-events-microsoft-excel%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3E%20Chart%20Events%20in%20Microsoft%20Excel%3C%2FA%3E.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

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.