Chart.GetChartElement (Excel)

Returns information about the chart element at specified x and y coordinates. This method is unusual in that you specify values for only the first two arguments. Microsoft Excel fills in the other arguments, and your code should examine those values when the method returns.

The value of ElementID after the method returns determines whether Arg1 and Arg2 contain any information, as shown in the following table.

GetChartElement (x, y, ElementID, Arg1, Arg2)


Dim lngx As Long: lngx = 
Dim lngy As Long: lngy = 
Dim lngElementID As Long: lngElementID = 
Dim lngArg1 As Long: lngArg1 = 
Dim lngArg2 As Long: lngArg2 = 
ActiveChart.GetChartElement x:=lngx, y:=lngy, ElementID:=lngElementID, Arg1:=lngArg1, Arg2:=lngArg2

Arguments

The following arguments are required:

x (Long) - The x coordinate of the chart element.

y (Long) - The y coordinate of the chart element.

ElementID (Long) - When the method returns, this argument contains the XLChartItem value of the chart element at the specified coordinates. For more information, see the Remarks section.

Arg1 (Long) - When the method returns, this argument contains information related to the chart element. For more information, see the Remarks section.

Arg2 (Long) - When the method returns, this argument contains information related to the chart element. For more information, see the Remarks section.