I am using the below code to search a column for a specific number, in this case 2603, and if 2603 is present it deletes the entire row.
Dim rng As Range, cell As Range, del As Range
Range("V:V").Select
Set rng = Intersect(Range("V:V"), ActiveSheet.UsedRange)
For Each cell In rng
If UCase(cell.Value) = "2603" Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next
del.EntireRow.Delete
The problem that I have is this: If the data in Range("V:V") does not have any 2603's in it, the macro fails since it did not find any 2603's. I need to know if there is something that I can add to the macro to allow the code to continue on if no 2603's exist in the data. Thanks!
Dim rng As Range, cell As Range, del As Range
Range("V:V").Select
Set rng = Intersect(Range("V:V"), ActiveSheet.UsedRange)
For Each cell In rng
If UCase(cell.Value) = "2603" Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next
del.EntireRow.Delete
The problem that I have is this: If the data in Range("V:V") does not have any 2603's in it, the macro fails since it did not find any 2603's. I need to know if there is something that I can add to the macro to allow the code to continue on if no 2603's exist in the data. Thanks!
