Finding last row of data depending on cell value?

TheWennerWoman

Active Member
Joined
Aug 1, 2019
Messages
270
Office Version
  1. 365
Platform
  1. Windows
Hello everyone.

To find the last row of data I have always used
Code:
Dim lastrowup As Long

With ActiveSheet
    lastrowup = .Cells(Rows.Count, "A").End(xlUp).Row
End With

This works fine. However, I have a situation where column A (starting at A4) will contain "Post" (via a formula based on other cell contents). There might be five of these (A4 thru A8), there might be fifty thousand (A4 thru A50003); however, at some point "Post" will become "Do Not Post".

I want to find the last row in column A containing "Post", I am not interested in "Do Not Post".......is there a quick hack to the above code I can use?

Many thanks for your time as always.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
VBA Code:
Dim lc As Range
Set lc = [A:A].Find(What:="Post", After:=[A1], LookIn:=xlFormulas, LookAt:=xlWhole, SearchDirection:=xlPrevious)
If Not lc Is Nothing Then lastrowup=lc.Row.
 
Upvote 0
Solution
VBA Code:
Dim lc As Range
Set lc = [A:A].Find(What:="Post", After:=[A1], LookIn:=xlFormulas, LookAt:=xlWhole, SearchDirection:=xlPrevious)
If Not lc Is Nothing Then lastrowup=lc.Row.

Spot on, many thanks :)
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

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