Find the Row Number of a selected table cell

myfathersson

New Member
Joined
May 4, 2010
Messages
22
Hi.

I'm sure this is easy but I'm darned if I can figure it out.

I want to load a table record into a form based on the current row, i.e., the row containing the selected cell. I already have the VBA code to load the form based on a row number relative to a column range in the databodyrange of the table. The row number in this code is supplied by match.

How can I find out what the row number is of the row containing the selected cell where the row number is relative to the rows in the table databodyrange?

Usage: I have a form I use to add and modify table records (rows). When modifying data, I enter a transaction number in the form which then looks up the transaction number using Match, which returns the row number (location in the column range) and then the form loads the data for that record. After making changes the form writes the record out, overwriting the old data for that record with the new data. I want to be able to do a search in the table outside of the form and then load the data from the record (row) in which search selected the cell containing the found data. For instance, if search selected a cell in table row 3, then I need a way to return table row number 3.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Well I found a solution...
Code:
iTableRowNum=ActiveCell.Row -_
ActiveSheet.ListObjects("Mytable").DataBodyRange.Rows(1).Row + 1

...don't know if there's a better one; at least it works.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,471
Messages
6,124,999
Members
449,201
Latest member
Lunzwe73

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top