I have the below line of code as part of my VBA .
As shown below, the first "find " section looks for the word "Paris". When it finds the work Paris, it updates the cell value as France and then moves on to the 2nd "find" section where it looks for the word "London and then updates the cell value as England.
The problem I have with this is that when the code does not find the word "Paris", it shows up an error. Is there a way to modify the below code in such a way that even if the word "paris" is not found in the first "find" section, the vba will still continue to look for the work "London" in the 2nd "find" section without giving an error message.
Cells.find(What:="Paris", After:= _
ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 0).Select
Do Until ActiveCell.Value <> ""
If ActiveCell.Value = "" Then
ActiveCell.Value = "France"
End If
ActiveCell.Offset(1, 0).Select
loop
Cells.find(What:="London", After:= _
ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 0).Select
Do Until ActiveCell.Value <> ""
If ActiveCell.Value = "" Then
ActiveCell.Value = "England"
End If
ActiveCell.Offset(1, 0).Select
Loop
===========================================
As shown below, the first "find " section looks for the word "Paris". When it finds the work Paris, it updates the cell value as France and then moves on to the 2nd "find" section where it looks for the word "London and then updates the cell value as England.
The problem I have with this is that when the code does not find the word "Paris", it shows up an error. Is there a way to modify the below code in such a way that even if the word "paris" is not found in the first "find" section, the vba will still continue to look for the work "London" in the 2nd "find" section without giving an error message.
Cells.find(What:="Paris", After:= _
ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 0).Select
Do Until ActiveCell.Value <> ""
If ActiveCell.Value = "" Then
ActiveCell.Value = "France"
End If
ActiveCell.Offset(1, 0).Select
loop
Cells.find(What:="London", After:= _
ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 0).Select
Do Until ActiveCell.Value <> ""
If ActiveCell.Value = "" Then
ActiveCell.Value = "England"
End If
ActiveCell.Offset(1, 0).Select
Loop
===========================================