Find last cell in a range

MrTeeny

Board Regular
Joined
Jul 26, 2017
Messages
238
At the moment I'm using the following to find the last cell but obviously it only searches the A column is there a way I can amend it to search more than one column say to AH, I imagine it's probably some simple syntax but I haven't been able to find it yet.

Thanks

Code:
Dim LrowRunners As Long
LrowRunners = sht_runners.Cells(sht_runners.Rows.Count, "A").End(xlUp).Row ' last row with data
 
Last edited:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
This will find the last row, regardless of column
Code:
    LrowRunners = sht_runners.Cells.Find("*", LookIn:=xlFormulas, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
 
Upvote 0
with range A:AH
Code:
LrowRunners = sht_runners.Range("A:AH").Find("*", LookIn:=xlFormulas, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0
This will find the last row, regardless of column
Code:
    LrowRunners = sht_runners.Cells.Find("*", LookIn:=[B][COLOR="#FF0000"]xlFormulas[/COLOR][/B], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
It is probably not going to apply to the OP's data, but one proviso for anyone reading this message with the idea of using the above code line in their own programs... specifying xlFormulas will make the Find method locate the last row with a constant or a formula in it even if that formula is displaying the empty text string (""). If you use xlValues instead of xlFormulas, then the row with the cell (whether it contains a constant or formula) that is displaying an actual value will be identified (even if there are formulas after it that return the empty text string).
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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