[VBA] Find LastRow within a Range

ExcelNooberino

New Member
Joined
Jan 2, 2019
Messages
43
Office Version
  1. 2016
Platform
  1. Windows
Hi guys! Hope y'all having a good summer under the circumstances...

So, I've been trying to create a dashboard to show some KPI of my own sector within the company and I'm stuck with some LastRow coding that I'm not getting out of, so, maybe you can give me a hand here.

Basically I have 3 tables, and for two of them I'm able to get the respective LastRow, but, the other one I just cant because it shares the same columns as the one of the others. For example, the first table goes from F7 to M39; the second table goes from O7 to V20; and the third table stays right below the second one, and it goes from O22 to V28. So the code that I got so far it's good for the first and third tables, like so:

VBA Code:
Dim wb As Workbook
Dim st As Worksheet
Dim LastRowDay As Long
Dim LastRowMonth As Long
Dim LastRowYear As Long

Set wb = ThisWorkbook
Set st = wb.Sheets("Paragens")

LastRowDay = Cells(st.Rows.Count, "K").End(xlUp).Row

LastRowYear = Cells(st.Rows.Count, "T").End(xlUp).Row

How can I get the LastRow for the second table, is there any way I can declare a specific range and get the last row for that range?!

If I'm not being clear please say so, so I can reformulate the text. Thanks in advance! ;)
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Try this for table two

VBA Code:
LastRowTable2 = Cells(st.Rows.Count, "T").End(xlUp).End(xlUp).End(xlUp).Row
 
Upvote 0
Solution

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

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