![]() |
Excel 2007 Tables - Get Active Cell Row and Column
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 |
Excel 2007 Tables - Get Active Cell Row and Column
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 -- p45cal *p45cal* ------------------------------------------------------------------------ p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=128166 |
Excel 2007 Tables - Get Active Cell Row and Column
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 "p45cal" wrote: 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 -- p45cal *p45cal* ------------------------------------------------------------------------ p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=128166 |
All times are GMT +1. The time now is 08:48 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com