Excel 2007 Tables - Get Active Cell Row and Column

T

TW Bake

Does anyone know a quick way to get the relative position (row and
column) of the selected cell within a table? I've tried a few
different items, but to no avail:

tmpRow = Selection.ListObject.Listrow
tmpRow = Selection.ListObject.ListRows.Index
tmpRow = Selection.ListObject.Range.Row
and others ...

I know it's got to be simple, but any help would be appreciated.

Thanks in advance,

TB
 
P

p45cal

depending on where you want to count as the top left cell, something
along these lines:Sub blah()
Set xxx = ActiveSheet.ListObjects(1)
Set yyy = Intersect(Selection, xxx.DataBodyRange)
If Not yyy Is Nothing Then
rw = Selection.Row - xxx.DataBodyRange.Row + 1
cl = Selection.Column - xxx.DataBodyRange.Column + 1
MsgBox Cells(rw, cl).Address
End If
End Sub
 
P

Patrick Molloy

I don't have access to v2007 just now, but something like

rowOffset = ActiveCell.Row - ActiveSheet.ListObjects(1).Row
colOffset = ActiveCell.Column - ActiveSheet.ListObjects(1).Column
 
Top