Hello Team,
I need your help in modifying the below code. Its serving the purpose. However, I have to click on the button more than once to get the desired result.
I am not sure, what is wrong in this code.
I need to delete columns older than 3 days. Everyday columns gets updated and I need to delete the column older than 3 days. 1st Row contains Date.
Sub Deleteolddata()
Dim ws As Worksheet
Dim LongCol As Long
Set ws = ActiveWorkbook.Sheets("Graph")
LongCol = ws.Cells(1, Columns.Count).End(xlToLeft).Column
For x = 1 To LongCol
If ws.Cells(1, x) <= Date - 3 Then
ws.Columns(x).Delete
End If
Next x
End Sub
Bookmarks