I have a worksheet with a bunch of data and I need to delete 2 adjacent columns if their date (found in row 2) is outside of a selected range. I have it sort of working, but it is deleting every other date outside the date range. I think it has something to do with the For Each, Next coding, but I can't figure a way around it. Any help is awesome! Here is my code so far:
Code:
Sub deleteColumns()
Dim rngDates As Range
Dim startDate As Date
Dim endDate As Date
Set rngDates = Worksheets("Temp").Range("M2:EE2")
startDate = Worksheets("Start").Range("B2")
endDate = Worksheets("Start").Range("B3")
Worksheets("Temp").Activate
For Each cell In rngDates
If cell = "" And cell.Offset(0, 1) <= startDate Or cell >= endDate Then
cell.Resize(, 2).EntireColumn.Delete
End If
Next cell
End Sub