Reputation: 10113
The following code will look for a cell containing 5/7 binnen 4h
and when it finds the cell it will copy the value of cell I on the same row to a different cell. Now there are a few cases when this text can't be found and I get an error. How could I handle this error?
Dim FoundRange As Range
Set FoundRange = Cells.Find("5/7 binnen 4h")
Range("I" & EmptyCell + 2).Value = Cells(FoundRange.Row, 9).Value
Upvotes: 1
Views: 24030
Reputation: 328608
Dim FoundRange As Range
Set FoundRange = Cells.Find("5/7 binnen 4h")
If Not FoundRange Is Nothing Then
Range("I" & EmptyCell + 2).Value = Cells(FoundRange.Row, 9).Value
Else
'you might want to do something if it is not found (msgbox...)
End If
Upvotes: 6