VBAProIWish
Well-known Member
- Joined
- Jul 6, 2009
- Messages
- 1,027
- Office Version
- 365
- Platform
- Windows
Hello All,
I have this simple macro below which works great for deleting rows with text and numbers, but doesn't work when trying to delete any row in the "Date" column that is prior to 04/01/2016. I'm sure there's some easy fix but I just can't figure it out.
Thanks for anything anyone can do to get this working
I have this simple macro below which works great for deleting rows with text and numbers, but doesn't work when trying to delete any row in the "Date" column that is prior to 04/01/2016. I'm sure there's some easy fix but I just can't figure it out.
VBA Code:
Sub Delete_rows_before_04_01_2016()
Dim nCol As Long
Dim cCol As Long
Dim rCount As Long
With ActiveSheet
nCol = Application.Match("Date", .Rows(1), 0)
cCol = Application.Match("Customer Number", .Rows(1), 0)
For rCount = Cells(.Rows.Count, cCol).End(xlUp).Row To 2 Step -1
Select Case .Cells(rCount, nCol).Value
Case Is < "04/01/2016"
.Rows(rCount).EntireRow.Delete
End Select
Next
End With
End Sub
Thanks for anything anyone can do to get this working