I have a task to return all the consecutive rows in a particular column. They will all have data consecutively and the first blank row will signal the end of the data. I used this to find the column and pass that over to my range, but I keep getting syntax errors.
Dim Col
Dim found As Boolean
Dim cellRange As Range
found = Cells.Find(What:="My_Search_Text", After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
'Take that column as the range.
If (found) Then
Col = ActiveCell.Column
cellRange = ActiveSheet.Range(Col, ActiveSheet.Range(Col).End(xlDown)).Select
The goal here is to get the correct range of cells and loop through them, however, I’m not at the loop part as the last line is the one that doesn’t work at all.
So what is the correct syntax for this last line and is there a better way to accomplish what I’m trying to do?
Try the following which I have tested with a selection of situations.
I have included notes about the changes I have made but come back with questions if anything is unclear.