ChetShannon
Board Regular
- Joined
- Jul 27, 2007
- Messages
- 133
- Office Version
- 365
- Platform
- Windows
Greetings.. I am trying to find occurrences of text (Airbillnbr) & corresponding row number(s) in an excel sheet but I am getting an error message when I run this code. The code must be defective because it's not finding the AirbillNbr like it should. My hope is to keep cycling through the FIND until I find the last instance of Airbill because there may be 0, 1 or n occurrences of AirbillNbr in the file. Thanks in advance for your help.
I understand with the FIND statement you have to account for the nothing found situation as well or I may just find one occurrence and then after that 1 occurrence I'd show no more of that particular airbill and the nothing found case would apply after that too I guess.
Set RangeLook = ActiveSheet.Range(Cells(TargetRow + 1, 1), Cells(MaxRowDOR, 1))
Set FindResult = RangeLook.Find(What:=Airbillnbr, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If FindResult Is Nothing Then
Windows(Airbills).Activate
GoTo NextAirbillItem
Else
TargetRow = ActiveCell.Row
Target = Cells(TargetRow, 1)
Cells(TargetRow, 1).Select
End If
I understand with the FIND statement you have to account for the nothing found situation as well or I may just find one occurrence and then after that 1 occurrence I'd show no more of that particular airbill and the nothing found case would apply after that too I guess.
Set RangeLook = ActiveSheet.Range(Cells(TargetRow + 1, 1), Cells(MaxRowDOR, 1))
Set FindResult = RangeLook.Find(What:=Airbillnbr, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If FindResult Is Nothing Then
Windows(Airbills).Activate
GoTo NextAirbillItem
Else
TargetRow = ActiveCell.Row
Target = Cells(TargetRow, 1)
Cells(TargetRow, 1).Select
End If
Last edited: