+ Reply to Thread
Results 1 to 7 of 7

Hide Columns based on Date

  1. #1
    Registered User
    Join Date
    01-22-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    55

    Hide Columns based on Date

    Hi all,

    Thanks for taking the time to read this.

    I posted previously with a similar macro hiding columns based on cell values.

    I am trying to take it further by changing the cell values to dates rather than integers but am falling a bit short on my modifications to the macro. 

    The macro should work but hiding columns with row values less than / greater than cells C5 / C6. Cells C5 / C6 are in date format. The row values are in date format.

    If either of cells C5 or C6 are blank, the macro does not run by design.

    When I run the macro by changing a cell at present everything becomes hidden with no range of dates showing…

    The code is below:

    Please Login or Register  to view this content.
    Can anyone please help? It would be very much appreciated!

    Kind regards,

    Coeus.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Hide Columns based on Date

    Hi,

    Not entirely sure what you are expecting to happen if either C5 or C6 are blank, other than nothing should happen by virtue of
    Please Login or Register  to view this content.
    where the range r interest is C5:C6
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Hide Columns based on Date

    hi Coeus, change this:
    Please Login or Register  to view this content.
    to this:
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    01-22-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Hide Columns based on Date

    Hi watersev,

    That worked a treat! Really appreciate it.

    Would you mind explaining to me where I was going wrong? Though I can see the difference unsure how it actually has corrected it!


    Many thanks,

    Coeus.

  5. #5
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Hide Columns based on Date

    IsDate returns True or False, you can not compare that to a date and get correct result

  6. #6
    Registered User
    Join Date
    01-22-2013
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Hide Columns based on Date

    Many thanks for your fast replies.

    I have had one issue but created a work around - perhaps you might have a better answer?

    The dates ranges in the columns is contained within a table. When the macro runs it does not gide any dates < the start date.

    When I change the range of i to dates not contained in tables it runs with no issues!

    Perhaps something to do with the table storing headers as text?


    Again many thanks for your help learning alot.


    Regards,


    Coeus.

  7. #7
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Hide Columns based on Date

    my option

    Please Login or Register  to view this content.

+ 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. VBA to hide columns based on input date range
    By Jace15 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 04-15-2021, 04:00 AM
  2. [SOLVED] Hide Columns Based on Date Selection
    By overbomb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-06-2013, 11:54 AM
  3. [SOLVED] Hide Columns based on date
    By Blue Fishey in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-15-2012, 12:28 AM
  4. [SOLVED] hide columns based on date
    By mattmorris in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-26-2012, 05:10 AM
  5. Hide Columns automatically based on date
    By chrisjc19 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-06-2011, 03:32 PM

Tags for this Thread

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