How to grab last row of first table of multiple in 1 sheet?

40 Views Asked by At

Hi I am trying to grab the last row in a table. Thing is, there's multiple tables in one sheet. Picture of excel file format for reference:

enter image description here

Usually I know I can like set a variable to refer to the last row via

lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row

But in this case, with that line I end up grabbing the last row of the VERY LAST table way down below. (like row 90)

Is there any way I can grab the last row of the first table? (In this case it'd be row 16)

1

There are 1 best solutions below

0
Kurt On

its hard to tell exactly what you need based on the example tables being blank. But you could try this, assuming each cell in column B of the first table is going to contain data / not be blank:

Sub Select_LastRow()

LastRowOfTable1 = Range("B3:B" & Rows.Count).Cells.SpecialCells(xlCellTypeBlanks).Row - 1

Range("B" & LastRowOfTable1).Select

End Sub