Finding last row of data depending on cell value?

TheWennerWoman

Board Regular
Joined
Aug 1, 2019
Messages
60
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.
 

Some videos you may like

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

footoo

Well-known Member
Joined
Sep 21, 2016
Messages
3,206
Office Version
  1. 2016
Platform
  1. Windows
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.
 
Solution

Watch MrExcel Video

Forum statistics

Threads
1,127,586
Messages
5,625,658
Members
416,124
Latest member
DeMoNloK

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
Top