ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find x-y coordinates of cell? (https://www.excelbanter.com/excel-programming/411791-find-x-y-coordinates-cell.html)

Sun Tzu

Find x-y coordinates of cell?
 
How can I find the x-y coordinates of the upper-left corner of a cell?

I want to insert two overlapping rectangles (msoShapeRectangle) of
different colors into the cell to illustrate the percentage value
displayed in an adjacent cell. Row heights an column widths on the
sheet are not predictable.

Thanks,
Wes

Gary''s Student

Find x-y coordinates of cell?
 
Sub whereAmI()
MsgBox (ActiveCell.Top & Chr(10) & ActiveCell.Left)
End Sub


Note that if you select A1 you get 0,0

So it is relative to the top of the shorksheet, not the top of the
application.
--
Gary''s Student - gsnu2007i


"Sun Tzu" wrote:

How can I find the x-y coordinates of the upper-left corner of a cell?

I want to insert two overlapping rectangles (msoShapeRectangle) of
different colors into the cell to illustrate the percentage value
displayed in an adjacent cell. Row heights an column widths on the
sheet are not predictable.

Thanks,
Wes


Peter T

Find x-y coordinates of cell?
 
Sub test()
Dim rng As Range
Dim shp As Shape

Set rng = Range("B2:D3")
With rng
Set shp = ActiveSheet.Shapes.AddShape( _
msoShapeRectangle, _
.Left, .Top, .Width, .Height)
End With

shp.Fill.ForeColor.SchemeColor = 7 + 6

End Sub

Regards,
Peter T

"Sun Tzu" wrote in message
...
How can I find the x-y coordinates of the upper-left corner of a cell?

I want to insert two overlapping rectangles (msoShapeRectangle) of
different colors into the cell to illustrate the percentage value
displayed in an adjacent cell. Row heights an column widths on the
sheet are not predictable.

Thanks,
Wes




Sun Tzu

Find x-y coordinates of cell?
 
On May 30, 11:47*am, "Peter T" <peter_t@discussions wrote:
Sub test()
Dim rng As Range
Dim shp As Shape

Set rng = Range("B2:D3")
With rng
* * Set shp = ActiveSheet.Shapes.AddShape( _
* * * * * * * * msoShapeRectangle, _
* * * * * * * * .Left, .Top, .Width, .Height)
End With

shp.Fill.ForeColor.SchemeColor = 7 + 6

End Sub

Regards,
Peter T

"Sun Tzu" wrote in message

...



How can I find the x-y coordinates of the upper-left corner of a cell?


I want to insert two overlapping rectangles (msoShapeRectangle) of
different colors into the cell to illustrate the percentage value
displayed in an adjacent cell. *Row heights an column widths on the
sheet are not predictable.


Thanks,
Wes- Hide quoted text -


- Show quoted text -


Thank you!

Sun Tzu

Find x-y coordinates of cell?
 
On May 30, 11:46*am, Gary''s Student
wrote:
Sub whereAmI()
MsgBox (ActiveCell.Top & Chr(10) & ActiveCell.Left)
End Sub

Note that if you select A1 you get 0,0

So it is relative to the top of the shorksheet, not the top of the
application.
--
Gary''s Student - gsnu2007i



"Sun Tzu" wrote:
How can I find the x-y coordinates of the upper-left corner of a cell?


I want to insert two overlapping rectangles (msoShapeRectangle) of
different colors into the cell to illustrate the percentage value
displayed in an adjacent cell. *Row heights an column widths on the
sheet are not predictable.


Thanks,
Wes- Hide quoted text -


- Show quoted text -


Thank you!


All times are GMT +1. The time now is 07:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com