Hi, I really need your help!
I have a set of data with X and Y values.
From the set I create a scatter plot.
I now would like to write a VBA to do the following.
The user should click on a point in the scatter plot.
After that the user clicks on a bottom which triggers the VBA.
The VBA should extract the X and Y coordinate of the point in the chart and write it to a cell.
Can you help me with that?
I already have the following code, but it doesn't work?
Sub GetCoordinates() Dim IDNum As Long, a As Long, b As Long, arrX, arrY, X_Wert, Y_Wert Dim x As Long Dim y As Long Dim sc As Series ActiveChart.GetChartElement x, y, IDNum, a, b If IDNum = 28 Then MsgBox "gut" Set sc = ActiveChart.SeriesCollection(a) arrX = sc.XValues arrY = sc.Values X_Wert = arrX(b) Y_Wert = arrY(b) ThisWorkbook.Sheets("Sheet1").Range("C1").Value = valueX Else MsgBox "Please click on a series in the chart." End If End Sub
Thanks a lot!
Best!


Reply With Quote
