VBAProIWish
Well-known Member
- Joined
- Jul 6, 2009
- Messages
- 1,027
- Office Version
- 365
- Platform
- Windows
Here's the code...
It's supposed to delete any rows in the "North" column unless the "Event" column says "123", "124" or "125", but it deletes those rows also.
If I change the numbers to any text, it will keep those rows. Can this be modified to work on numbers and text?
Thanks much
Code:
Sub Del_Rows_w_X_inColX_Unless()
Dim cell_to_check As Variant
Dim range_to_check As Range
Dim nCol As Long
Dim nCol2 As Long
Dim rCount As Long
With ActiveSheet
nCol = Application.Match("Region", .Rows(1), 0)
nCol2 = Application.Match("Event", .Rows(1), 0)
For rCount = .UsedRange.Rows.Count To 2 Step -1
Select Case UCase(.Cells(rCount, nCol2).Value)
Case "123", "124", 135"
'Do Nothing
Case Else
Select Case UCase(.Cells(rCount, nCol).Value)
Case "NORTH"
.Rows(rCount).EntireRow.Delete
End Select
End Select
Next
End With
End Sub
It's supposed to delete any rows in the "North" column unless the "Event" column says "123", "124" or "125", but it deletes those rows also.
If I change the numbers to any text, it will keep those rows. Can this be modified to work on numbers and text?
Thanks much