Close Window   
Free Ebook
Get Your Free Excel
Our Top 15 Excel Tutorials
Instant Access!
Subscribe for Free Excel tips & more!

Find Pixel Coordinates Of A Cell

Forum Register
Search Excel Forum Posts, Tutorials, Macros, Tips, and More

Anyone know of a way to get the pixel coordinate (say TOP) for a particular row. Currently, i use ActiveSheet.ChartObjects("chart 11").Top = 305 to move my chart to coordinate 305. However, when another user has a different screen resolution that's not the position I want. I need the pixel coordinate of Row 24. Anyone?

Thanks a million.

View Answers     

Similar Excel Tutorials

Quickly Replace A Lot of Data in Excel
The Find & Replace works much the same way as Find and is located in the same place. (Find & Select drop do ...
How to Quickly Find Data Anywhere in Excel
Finding specific records and/or cells is easy when using the Find tool in Excel. It is located within the Find & ...
Quickly Find All Comments in a Spreadsheet in Excel
In Excel, you can create a comment for any cell in the worksheet. The problem is that these comments are hard to f ...
Get the First Word from a Cell in Excel
How to use a formula to get the first word from a cell in Excel. This works for a single cell and an entire list or ...

Helpful Excel Macros

Get Values from a Chart
- This macro will pull the values from a chart in excel and list those values on another spreadsheet. This will get the s
Create a Line Chart with a Macro in Excel
- Create a line chart in Excel with this macro. This allows you to quickly and easily create line charts and graphs from
Create a Column Chart with a Macro in Excel
- This macro adds a column chart to Excel. This is an easy to use macro that allows you to quickly chart and graph a rang
Delete All Chart Sheets in Excel - Only Chart Sheets are Deleted - Not Embedded Charts
- Delete all chart sheets and tabs in Excel using this macro. This will only delete the charts and graphs that are in the
Print all Embedded Charts in the Entire Workbook
- This macro will print every embedded chart in the active workbook. If you have an embedded chart in any worksheet within

Similar Topics

I'm trying to return values of xy coordinates off of a particular data point from a series in a chart . My goal is to add a single line, based on a xy coordinate (pixel coordinate is what I believe I need) to a large number of charts. My difficulty lies in obtaining the xy coordinates, rather I believe all I really need is the x coordinate. I've been trying to use the ValueToPoint() function, but I can't seem to get it to work. The MSDN forum doesn't provide too much information, rather I can't find the file they're referencing in their example, so I can't trace to see how the code is supposedly to actually work. (The link to their help section is he The other code is not a problem of compiling, but I'm just missing the coordinate to reference where to start drawing. Any help would be greatly appreciated. Thanks.

Is there a way to capture the data from a DOS like screen (3rd party
software) without connecting to the database. May be using the coordinate
system / copying data to clip board and searching for specific string ect.?

The screen size and pixel / resolution will be consistent for all users.
The data will always be dispayed on a specific coordinate on the screen all
the time. The filed lengths are fixed as well.

Any help is appreciated.


I have never set column width before, If posibel could someone show me how to do it.

I have a sheet which i would like to set
Rows 5 and downward to height=30:00(40 pixels).
Column at diffrent width.
Column A = 4.43 (36 pixel)
Column B = 6.00 (47 pixel)
Column C = 16.71 (122 pixel)
Column D = 24.57 (177 pixel)
Column E = 15.86 (116 pixel)
Column F = 18.86 (137 pixel)

Not sure how to do this, have looked at lots of answers but more confused now.

If someone can assist.


I have a XY-scatter(with lines) chart where I even want to show the coordinates for each point in the chart. I manage to show either the x-coordinate or the y-coordinate but not both at the same time.
Hope someone can help me!!

I have two paired sets of XY (Cartesian coordinate) data. I need to correlate coordinate set Xa n Ya n with coordinate set Xb n Yb n from 1 to N. Formulaaaa suggestions or references?


I am wondering if there is a way of getting the x and y coordinates (in relation to x and y data) from wherever the mouse is clicked on a chart. I am not meaning x and y screen pixel coordinates, i need x, y coordinates for chart data.
For example lets say you have dollars on y axis, and product on x. If you click the mouse on the chart it would spit out the product number and dollars (from x and y coordinates on the chart) for the position of the mouse pointer.

How can I in Excels WorkSheet objects such as PlotArea or Shape using VBA and API determine pixel color at given coordinates. API function GetPixel requires handler - hdc so do Excels objects possess hdc and how can I get it? Or maybe there is another way to read pixel color ?

Say I have a list of XY coordinates, each in their own column. What I need to do is somehow mark each coordinate as falling into one of 3 categories, perhaps by some formula in another column:
- there is another XY coordinate that is EXACTLY 1 unit away in either the X OR Y direction
- there is another XY coordinate that is EXACTLY 50 unit away in either the X OR Y direction
- there is another XY coordinate that is EXACTLY 500 unit away in either the X OR Y direction
- other

0,0 (1 unit away)
0,0.1 (other)
0.1,0 (other)
1,1 (1 unit away)
2,2 (1 unit away)
3,3 (1 unit away)
100,100 (50 unit away)
100,150 (50 unit away)
150,100 (50 unit away)
500,500 (500 unit away)
500,1000 (500 unit away)
1000,1000 (500 unit away)

My list would not be ordered in any way.

(0,0) is not categorized as "other" due to the presence of (1,1). The "other" category is only used if there is no other coordinate that can be used to categorize.

What is the quickest way to do this? I may have more categories to add, but they would just be more if the same, only at different distances.

Also, is it possible to choose whether to use the "larger" (or "smaller") of the categories? For example, say we have these three coordinates.

0,50 (50 away)
150,50 (100 away)

But (50,50) could be either (50 away) or (100 away). I wouldn't consider any other categories except the two "nearest" categories; e.g. if there was one that fit (200 away), it wouldn't matter since there is one that fits (100 away).

I hope I explained my problem well enough!

My thanks to anyone who bothered to read this!

I created a program that works in Excel 2007 and 2010, but there is one sub that I cannot get to work in 2013 which does the following:

When there is a picture on the sheet (top left at cell AA1)
Set the cursor position onto a specific pixel location
Get cursor position
Get pixel color at that position
Set the fill color of the cell behind that position to the pixel color

I am wondering if there are any functions that I used that work differently in Excel 2013 compared to 2010 and 2007 because when I run the sub, every cell is turned to white (when obviously the image I am using is not just white). It would be a huge help if someone could identify what is causing the problem! Here is the code for that sub:

Please Login or Register  to view this content.

Hello VBA'liens,
I want to create a chart with 3 lines, whereas the 1st has it's y-coordinate
in column A and its x-coordinate in column B, the 2nd line has its y-coordinate in column C and its X-coordinate in column E, the 3rd line has its y-coordinate in column D and its X-coordinate also in column E.
Line 1 has 30 coordinates, Line 2 and 3 have 10 coordinates.
this is my code!


Sub Makro6()
ActiveChart.ChartType = xlLineMarkers
' y-coordinates of line 1 in column A 
ActiveChart.SetSourceData Source:=Sheets("Sheet").Range("A1:A30"), _
' X-coordinates of line 1 in column B 
ActiveChart.SeriesCollection(1).XValues = "=Sheet!R1C2:R30C2"
' X-coordinates of line 2 in column E
ActiveChart.SeriesCollection(2).XValues = "=Sheet!R1C5:R10C5"
'y-coordinates of line 2 in column C 
ActiveChart.SeriesCollection(2).Values = "=Sheet!R1C3:R10C3"
'X-coordinates of line 3 in column E
ActiveChart.SeriesCollection(3).XValues = "=Sheet1!R1C5:R10C5"
'y-coordinates of line 3 in column D
ActiveChart.SeriesCollection(3).Values = "=Sheet1!R1C4:R10C4"
ActiveChart.Location Whe =xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasAxis(xlCategory, xlPrimary) = False
.HasAxis(xlValue, xlPrimary) = True
End With
ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale
ActiveChart.HasDataTable = False
End Sub

I hope you understood my problem, excuse my bad English.
Hopefully someone knows the answer...

Best regards,


Im relatively new to VBA and as part of my final year project in college I have to create animations of mechanisms in excel for educational purposes. How does the coordinate system work when inserting a shape, I cant find any information on it? I know a A screen position has an X and a Y coordinate, with X increasing to the right and Y increasing downward. The origin (0,0) is the top left corner of the worksheet. how does that relate to top and left in code in VBA?



Hi. I have many (200+) charts, generated by a frequently updated Excel 2007 workbook, that I need to use in a website. The charts must be 500 pixels wide by 300 pixels tall. XL confirms these pixel dimensions, along with an absolute size of 5.2 inches by 3.1 inches (corresponding to a resolution of 96 DPI).

If I copy and paste one of these charts into another application as a PNG or BMP, the 500 x 300 pixel dimensions are maintained. So far, so good.

BUT, if I copy and paste the same chart as a GIF, it's 780 pixels wide by 470 pixels tall---far too big for my webpage. And, more significantly, I get the same (excessive) chart size if I save the entire workbook as a web page---the only practical option with 200+ frequently updated charts.

Windows reports the resolution of these bloated charts as 149 DPI. So, XL 2007 seems to be trying to maintain the original size of the charts in inches (5.2 x 3.1), rather than in pixels---but with a target resolution of 149 DPI.

The XL web options settings "screen size", "resolution", and "allow PNG as a graphics format" have no discernible effect on the chart size or resolution.

How can I get XL 2007 to maintain the original pixel dimensions during a "save as web page" operation, like previous versions? Alternatively, how can I force XL to use a desired resolution (e.g. 72 or 96 DPI instead of the mystery 149 DPI) for exported charts? Thanks in advance!

I would like to plot 3D coordinates on a 2D surface graph. Each coordinate set would have its own 'Number' as referenced in Attached spreadsheet. This number should be used for the Legend in the chart. In the example there should be 9 3D coordinate points and thus 9 items in the Legend.

I have labelled the axes how they should be set out I just cant seem to get the graph to work the way I have described above.

The resultant for the graph would be a 2D surface between the coordinate points. Maybe I am using the wrong type of graph but any help would be appreciated in trying to get this to work.


Hi all, I'm Javier from Spain. Have been checking this forum for some time and it has been very helpful

What I'm trying to do is to make a chart clickable so that when you click on the date axis it will zoom to that date. The clicked date should then be the minimum value of the graph.

I have tried lots of things but have been completely unable to get the point the user has clicked on. I can get the mouse x coordinate but cannot find a way to translate it to the point coordinate.

Could you please give me some hint to do that? I could either translate the coordinates or if you can think of any other way please tell me so

Thanks a lot!

I have several black rectangular shape objects with rounded corners on my 2007 sheet. I have each one sized as wide as the black colored cells they overlap (or so I think). I've zoomed in 400% to make sure they were lined up properly and they look great at 400%.

When I zoom out to 100%, every one of the rectangles are aligned left to each cell correctly, but they are all 1 pixel shorter and look to be 1 pixel short on the right side of the cell.

But then when I print the sheet, the rectangular shapes in the printout appear to be 1 pixel wider and hang off the right side of the cell by 1 pixel. The left side is still aligned correctly.

Does anyone know what is going on and how I could fix this?

I could just make them 1 pixel longer so it looks right when viewing at 100%, but then my printout will look like it is 2 pixels wider and hang off the right side of the cells by 2 pixels.

For some reason, I cannot get my worksheet to display a cell's pixel value when I make a colum or row wider. Thoughts?


Currently I am positioning a chart created with a vba macro by using


    With ActiveSheet.ChartObjects.Add _
            (Left:=325, Width:=750, Top:=600, Height:=300)

I would like to set the Top property with a cell. Is that possible? So instead of 600px I would like it to start at row 46 or whatever. I have multiple sets of data on a worksheet that need to be graphed. I would like to be able to position the graph by row instead of having to figure out where to start by pixel.

Hello Everyone,

I am importing some text files into an excel worksheet. I want to change the format just a little bit. For each date I have 5 rows (pixel: 25, 37, 50, 100, and 200). When I import my data the date is in the same row as my pixel numbers. I want to place the date in another column to the left of these pixel numbers.

Below is an example of my "spreadsheet" The first 5 lines (with date "2008_308.txt" next to each pixel number is what I want it to look like and the next (with date "2008_309.txt" is how it is imported with only one date above the pixel numbers. I could do this manually, but I have many years of data to import. And would like a way to kind of copy/paste these multiple items at the same time. Any ideas?


____________ Pixel Area(%) Cumm. Area Count Area (km^2)
2008_308.txt 25
2008_308.txt 37
2008_308.txt 50
2008_308.txt 100
2008_308.txt 200
____________ 2008_309.txt
____________ 25
____________ 37
____________ 50
____________ 100
____________ 200


Where is my error

Sub Open_hypersnap_Small()
   Dim shellstring As String
   Dim x1, Y1, W1, H1 As Integer
   Dim Coordinate As RANGE
   x1 = Application.WorksheetFunction.VLookup(RANGE("Graphnumber").Value,  RANGE("Coordinate"),  4, 0)

Coordinate is a range defined in my sheet

Mousse over Range("Coordinate") give "Nothing" message


I've never seen this kind of feature in any program so..

You know when you open a picture using windows paint,
there's a coordinate on the bottom right of the screen right?

Now, Is it possible to make a macro that records the coordinate everytime i maka a dot using "pencil" feature in paint?

So everytime i click on a spot in the image (draw a single dot), excel would track the coordinates of these dots and write it vertically in 2 columns (x & y)... the result is something like this :


x	y
125	148
143	180
152	185
230	155
280	186
280	154
207	133
207	70
246	95
281	121
282	94
337	82
320	95
342	100
356	109
350	159
346	202

I need to do this for 5000 dots so writing down those coordinates manually is gonna take forever, and the error risk is higher too ...

Or could you reccomend me a program that has such feature?
I've been googling it but found no such thing...


I have two paired sets of XY (Cartesian) data. I need to correlate coordinate set XaYa n with coordinate set XbYb n from 1 to N. Suggestions or references?


Hello, I am doing a project for an individual in which I load in an image to a excel sheet. Then on sheet 2 it shows the color of pixel in each cell according to the pixel location in the image. And on sheet 3 it shows the RGB value of each pixel in their according location in the sheet based on pixel location. I had this working all fine and dandy in Excel 2010, but they apparently need it in Excel 2013. I'm having some issues with the GetPixel API method in Excel 2013. When used in 2010 it retrieves the color of the pixel at the location I need just perfectly, but when used in Excel 2013 all it ever returns is -1. I'm coming here as a last resort to see if anyone has any idea of a work around for this or if this is a known issue at all. I've tried grabbing several different hwnd's, but have had no luck. Thanks so much.

Edit - Apparently I was just grabbing the wrong handle. All is well. Thanks anyways.

Does anyone have code that would give a source GPS coordinate when given multiple GPS coordinates and power levels? I know it won't be exact but given the input, hopefully provide a more accurate location of the source. Thanks!



Excuse me for my english, it's not my mother tongue.

I have one picture in my sheet named "Picture 1". When I click on this picture, I call
my routine "MyPicture_Click()".

In this macro, I call the 'GetCursorPos' API windows function to know the mouse
position. But coordinates are relative to the screen and not to sheet.

i.e., if my picture is in the upper left corner of my sheet, coordinates are not 0, 0.

Is there someone know how I can convert coordinate from 'GetCursorPos' to my
active sheet?



I have a problem I was hoping I could get some help with. Right now, I have a lot of information that, when plotted, forms a large "V" shape. I need to break that one plot down into smaller plots for easier consumption, starting from the middle (the minimum value of the y-coordinates) and working my back up one side of the x-y coordinate pairs. The new plots need to consist of 10-unit y-coordinate chunks (so, one plot would have y-values from 30-40, one from 40.1-50, etc.). I only need to do this from the minimum value on to the right (only the higher x-coordinate values). I'd really appreciate any help I can get. Thanks!