VBA: Find Header Return Last Row

Nine Zero

Well-known Member
Joined
Mar 10, 2016
Messages
625
Hello,

Been searching and searching and not quite what I am looking for.

Need to search Row(1) for the header "Total"

Return the last row used in the Column where the header "Total" was found

Thank you
 
Last edited:

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Try:
Code:
Dim LR  As Long
Dim r   As Long
On Error Resume Next
r = Cells(1, 1).UsedRange.Resize(1).Find(what:="Total", lookat:=xlWhole).Column
On Error GoTo 0
If r Then LR = Cells(Rows.Count, r).End(xlUp).Row
 
Upvote 0
Try:
Rich (BB code):
Dim LR  As Long
Dim r   As Long
On Error Resume Next
r = Cells(1, 1).UsedRange.Resize(1).Find(what:="Total", lookat:=xlWhole).Column
On Error GoTo 0
If r Then LR = Cells(Rows.Count, r).End(xlUp).Row

Keep getting on the red line
Run-time error '438':
Object doesn't support this property or method
 
Upvote 0
Change line in red to:
Code:
r = Cells(1, 1).EntireRow.Find(what:="Total", lookat:=xlWhole).Column
and try (tested and r = 17 if I put "Total" into Q1)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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