Excel Guides

Determining Mouse Cursor Coordinates On a Graphic in Excel

There are a few different ways that you can determine the mouse cursor coordinates on a graphic in Excel. One way is to use the built-in "GetPixel" function. This function takes two parameters - the x and y coordinates of the pixel you want to retrieve. For example, if you wanted to find out the color of the pixel at position (5, 10) on a graphic, you would use the following code:

x = 5
y = 10
color = GetPixel(x, y)

Another way to determine the mouse cursor coordinates on a graphic is to use the "Mouse" object. This object has a "Position" property that returns the x and y coordinates of the mouse cursor. For example, if you wanted to find out the position of the mouse cursor when the user clicks on a button, you would use the following code:

button.OnClick()
x = Mouse.Position.X
y = Mouse.Position.Y

Move beyond 

Excel

Get started with Causal today.
Build models effortlessly, connect them directly to your data, and share them with interactive dashboards and beautiful visuals.