+ Reply to Thread
Results 1 to 5 of 5

Delete entire Columns based on Date

Hybrid View

hftechno Delete entire Columns based... 12-18-2020, 12:01 PM
nankw83 Re: Delete entire Columns... 12-18-2020, 12:07 PM
hftechno Re: Delete entire Columns... 12-18-2020, 12:27 PM
nankw83 Re: Delete entire Columns... 12-18-2020, 12:28 PM
Sintek Re: Delete entire Columns... 12-18-2020, 12:49 PM
  1. #1
    Forum Contributor
    Join Date
    10-04-2014
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    161

    Delete entire Columns based on Date

    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.
    Attached Files Attached Files

  2. #2
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,713

    Re: Delete entire Columns based on Date

    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

  3. #3
    Forum Contributor
    Join Date
    10-04-2014
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    161

    Re: Delete entire Columns based on Date

    perfect, thanks so much!

  4. #4
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,713

    Re: Delete entire Columns based on Date

    Glad to help & thanks for the added Reps.

  5. #5
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Delete entire Columns based on Date

    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 Range("A2").Resize(, Cells(1, Columns.Count).End(xlToLeft).Column)
    With this snippet...
    With Range("A" & Cells(Rows.Count, 1).End(xlUp).Row + 1).Resize(, Cells(1, Columns.Count).End(xlToLeft).Column)
    Attached Files Attached Files
    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!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Delete Columns Macro, Based on Creating a Fiscal Year, Based on Today's Date
    By DemRulesDoe in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-23-2018, 11:02 AM
  2. [SOLVED] Delete certain columns instead of entire row
    By wjk221 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-29-2014, 10:20 AM
  3. [SOLVED] Delete entire Columns based on different Headers (Array)
    By WITJ in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-13-2013, 02:46 PM
  4. Replies: 3
    Last Post: 11-06-2012, 11:26 AM
  5. [SOLVED] Excel 2007 : Format entire columns based on date at head of column
    By CakeBloke in forum Excel General
    Replies: 2
    Last Post: 06-07-2012, 07:44 AM
  6. Macro to delete entire rows based values in columns
    By shamade2107 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2009, 11:17 AM
  7. Delete an entire Row if 2 Columns = Zero Q
    By John in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2005, 02:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1