以下代码将查找包含5/7 binnen 4h
的单元格,当它找到单元格时,它会将同一行中单元格I的值复制到另一个单元格。现在有一些情况下无法找到此文本,我收到错误。我怎么能处理这个错误?
Dim FoundRange As Range
Set FoundRange = Cells.Find("5/7 binnen 4h")
Range("I" & EmptyCell + 2).Value = Cells(FoundRange.Row, 9).Value
答案 0 :(得分:5)
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