+ Reply to Thread
Results 1 to 8 of 8

Macro; Hide Columns; VBA

  1. #1
    Registered User
    Join Date
    03-09-2012
    Location
    N/A
    MS-Off Ver
    MS 365
    Posts
    70

    Macro; Hide Columns; VBA

    CF Checklist.xlsm

    Hi

    I've sourced the initial template from the web, then added other elements, one of which is to Hide Columns based on Date (month) selected

    However, this is now working - see attached and I can't figure out why

    Would be very grateful if someone could have a look and advise...

    Let me know when you can

    Thanks, Maddy
    Last edited by overbomb; 10-16-2013 at 07:00 AM. Reason: unprotect

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,440

    Re: Macro; Hide Columns; VBA

    The worksheet is protected with a password. The easy way out is to unprotect it at the start of the code and protect it again at the end.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    03-09-2012
    Location
    N/A
    MS-Off Ver
    MS 365
    Posts
    70

    Re: Macro; Hide Columns; VBA

    have attached unprotected version now - apologies

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,440

    Re: Macro; Hide Columns; VBA

    OK, two problems, potentially: 1) you are comparing a date value in the cell to a text string in the code and 2) you are, in all cases, comparing cell C1 rather than a cell in the column with a date in it.

    So you need something like:

    Please Login or Register  to view this content.

    So, in the last example, you would need to change C1 to H5 and add the DateValue function around the text date.

    You may or may not have to unprotect the sheet depending on how you have set up the protection.


    Regards, TMS

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,440

    Re: Macro; Hide Columns; VBA

    Oh, and you'd probably be better looping through the range than doing the long IF THEN ELSE ... bit tedious and repetitive.


    Actually, a follow up on the previous post: should actually be comparing the value in cell F5, G5, H5, etc with the value in cell D1 ... not a fixed text value.


    Regards, TMS
    Last edited by TMS; 10-21-2013 at 10:33 AM. Reason: typo

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,440

    Re: Macro; Hide Columns; VBA

    Like this:

    Please Login or Register  to view this content.

    Regards, TMS

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,440

    Re: Macro; Hide Columns; VBA

    Thanks for the rep.


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  8. #8
    Registered User
    Join Date
    03-09-2012
    Location
    N/A
    MS-Off Ver
    MS 365
    Posts
    70

    Re: Macro; Hide Columns; VBA

    thank you for that

    was wondering how to mark it solved

    maddy

+ 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. Macro to Hide Columns Where Sum is Zero
    By mgordon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-21-2013, 10:17 PM
  2. Macro to Hide Columns
    By Shazz in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-24-2013, 10:32 AM
  3. Hide Columns via a Macro
    By Foxcan in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-11-2009, 10:38 AM
  4. hide columns macro
    By xkarenxxxx in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-02-2006, 12:35 PM
  5. [SOLVED] macro to hide columns
    By Shooter in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-27-2005, 05:05 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