Hello,
I have a short macro that loops thru a range, and for each row:
1. grabs a value from the row
2. looks for that value in another sheet
3. copies a range once the value is found
4. returns to the first sheet and pastes the copied data.
The loop works 100% if every value is found, but I naturally get an error if the value it's looking for is not found. I don't know how to get the loop to bypass the error and go to the next row to search for the next value. I'm am somewhat familiar with error handling and I can get this work in a non-loop version but cannot get past the error in a loop.
Any help would be much appreciated.
I have a short macro that loops thru a range, and for each row:
1. grabs a value from the row
2. looks for that value in another sheet
3. copies a range once the value is found
4. returns to the first sheet and pastes the copied data.
The loop works 100% if every value is found, but I naturally get an error if the value it's looking for is not found. I don't know how to get the loop to bypass the error and go to the next row to search for the next value. I'm am somewhat familiar with error handling and I can get this work in a non-loop version but cannot get past the error in a loop.
Any help would be much appreciated.
VBA Code:
Sub Find_Categories()
'
Application.ScreenUpdating = False
'
Range("F1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, 5).Range("A1").Select
Range(Selection, "K2").Select
For Each Cell In Selection
If Cell.Value = 0 Then
'
ThisWorkbook.Activate
ActiveSheet.Select
Dim Title1 As String
Title1 = Range("E" & ActiveCell.Row)
Workbooks("Reference For Billing.xlsm").Activate
Sheets("New Releases").Select
Range("A1").Select
'the error occurs at this line when it can't find the value
Cells.Find(What:=Title1, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
Range("D" & ActiveCell.Row & ":" & "E" & ActiveCell.Row).Copy
ThisWorkbook.Activate
Range("L" & ActiveCell.Row).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.Offset(1, 0).Range("A1").Select
'
Else: ActiveCell.Offset(1, 0).Range("A1").Select
End If
Next Cell
'
Application.ScreenUpdating = True
'
End Sub