I have a table of data which is broken up by a number of blank rows at irregular spacing. I need to find the row number of the next blank row after the last occurance of a string in col A---which can be somewhere in the middle of the data table. I've got the row number of the last occurence of FRED, as an example, below but am stuck finding the next blank row. FRED is effectively a heading with rows of other data below his name followed by a blank row.
Would be grateful for a steer in the right direction.
thanks
Geoff
Code:
Sub find_occurance_of_string()
Dim FirstRow As Long
Dim LastRow As Long
Dim erow As Long
With Sheets("DATA")
FirstRowPFW = Range("A:A").Find(what:="FRED", after:=Range("A1")).Row
LastRowPFW = Range("A:A").Find(what:="FRED", after:=Range("A1"), searchdirection:=xlPrevious).Row
End With
MsgBox FirstRow & vbCrLf & LastRow
'empty row after last row containing FRED in col A
erow = Sheets("DATA").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
MsgBox erow
End Sub
Would be grateful for a steer in the right direction.
thanks
Geoff