ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Returning the position of the Cellpointer in the range (https://www.excelbanter.com/excel-programming/377489-returning-position-cellpointer-range.html)

John

Returning the position of the Cellpointer in the range
 
Hi,

The Table below is called Tbl_AgeProfile. I'd like to be able to return
the row and column offset of the Cellpointer from R1. EG if the Cellpointer
is highlighting the cell with the value 91, i want to return 5,4 where 5 is
the row down and 4 is the column across. Any ideas please?

Thanks

John

R1 R2 R3 R4 R5 R6
2 20 418 590 135 29
0 11 74 189 68 3
2 8 51 95 85 3
1 11 53 91 27 4
2 14 16 75 14 1
0 16 14 135 31 1
1 5 0 0 0 0


Chip Pearson

Returning the position of the Cellpointer in the range
 
Try something like

Dim R As Long
Dim C As Long
R = ActiveCell.Row - Range("Tbl_AgeProfile")(1, 1).Row
C = ActiveCell.Column - Range("Tbl_AgeProfile")(1, 1).Column
Debug.Print R, C


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"John" wrote in message
...
Hi,

The Table below is called Tbl_AgeProfile. I'd like to be able to return
the row and column offset of the Cellpointer from R1. EG if the
Cellpointer
is highlighting the cell with the value 91, i want to return 5,4 where 5
is
the row down and 4 is the column across. Any ideas please?

Thanks

John

R1 R2 R3 R4 R5 R6
2 20 418 590 135 29
0 11 74 189 68 3
2 8 51 95 85 3
1 11 53 91 27 4
2 14 16 75 14 1
0 16 14 135 31 1
1 5 0 0 0 0




John

Returning the position of the Cellpointer in the range
 
Hi Chip,

Cool, thanks

John

"Chip Pearson" wrote:

Try something like

Dim R As Long
Dim C As Long
R = ActiveCell.Row - Range("Tbl_AgeProfile")(1, 1).Row
C = ActiveCell.Column - Range("Tbl_AgeProfile")(1, 1).Column
Debug.Print R, C


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"John" wrote in message
...
Hi,

The Table below is called Tbl_AgeProfile. I'd like to be able to return
the row and column offset of the Cellpointer from R1. EG if the
Cellpointer
is highlighting the cell with the value 91, i want to return 5,4 where 5
is
the row down and 4 is the column across. Any ideas please?

Thanks

John

R1 R2 R3 R4 R5 R6
2 20 418 590 135 29
0 11 74 189 68 3
2 8 51 95 85 3
1 11 53 91 27 4
2 14 16 75 14 1
0 16 14 135 31 1
1 5 0 0 0 0






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

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