I'm trying to delete a range of columns that have dates (starting at 9/1/2017) as headers. I need it to delete from 9-2017 -> 8-2018, but when I run the code it keeps: Sep-17, Oct-17, and deletes Sep-18 and Oct-18. I'm not quite sure what is happening. Here is the code:
Code:
Dim dateStart, dateEnd, dateStartAdd, dateEndAdd, startCol, endCol As Variant
With ws.Range("C1:CY1")
Set dateStart = .Find(What:="Sep-10", LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
Set dateEnd = .Find(What:="Aug-17", LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
dateStartAdd = dateStart.Address
dateEndAdd = dateEnd.Address
startCol = Split(dateStartAdd, "$")(1)
endCol = Split(dateEndAdd, "$")(1)
.Columns(startCol & ":" & endCol).EntireColumn.Delete
End With
Last edited by a moderator: