Looking for a macro that will delete the entire column if the Date value is less than Todays Month & Year.
See attached example.
Thanks in advance.
Looking for a macro that will delete the entire column if the Date value is less than Todays Month & Year.
See attached example.
Thanks in advance.
Hi hftechno,
Try below code ...
![]()
Sub test() With ActiveSheet.UsedRange For x = .Columns.Count To 1 Step -1 If .Cells(1, x) < Application.EoMonth(Date, -1) + 1 Then .Columns(x).Delete Next End With End Sub
If I was able to help, you can thank me by clicking the * Add Reputation under my user name
perfect, thanks so much!
Glad to help & thanks for the added Reps.![]()
Testing 123....And yet another snippet of code that gets Securi walled....
Code.png
I know this is solved...I always try for a non looping option too...See code in file...cannot post...
If Rows below 1 are filled then
Replace this snippet....
With this snippet...![]()
With Range("A2").Resize(, Cells(1, Columns.Count).End(xlToLeft).Column)
![]()
With Range("A" & Cells(Rows.Count, 1).End(xlUp).Row + 1).Resize(, Cells(1, Columns.Count).End(xlToLeft).Column)
Last edited by Sintek; 12-19-2020 at 02:08 AM.
Good Luck...
I don't presume to know what I am doing, however, just like you, I too started somewhere...
One-day, One-problem at a time!!!
If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
Also....Add a comment if you like!!!!
And remember...Mark Thread as Solved...
Excel Forum Rocks!!!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks