+ Reply to Thread
Results 1 to 13 of 13

Need macro to hide column based on cell value

  1. #1
    Registered User
    Join Date
    06-21-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2003
    Posts
    9

    Need macro to hide column based on cell value

    I'm looking for a macro that will allow me to hide columns based on a cell value

    I want the macro to HIDE all columns with "Hide" in Row1 and SHOW all columns that are "blank" in Row1. I've seen many posts on this topic, but I'm not skilled enough in this area to edit them to fit my situation.

    Thanks in advance for your assistance!

    KD

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Need macro to hide column based on cell value

    The basic idea would be

    Please Login or Register  to view this content.
    How do you want this to run?
    Last edited by jeffreybrown; 06-26-2012 at 10:58 PM.
    HTH
    Regards, Jeff

  3. #3
    Registered User
    Join Date
    06-21-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Need macro to hide column based on cell value

    The intent was to create a macro button for the user. The sheet called "Worksheet" is pulling data from an Essbase retrieve. The user would refresh their retrieve and then run the "update" macro to hide the columns with no data. However, I welcome any better solutions.

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Need macro to hide column based on cell value

    So initially you said hide all the column with hide? Is the user going to enter the word hide?

    Look at the post above and I updated the macro to the particular sheet you identified.

    The best thing is to work with your data and see if this works for you, but not I don't necessarily have a better solution as I don't know your entire process.

    I am calling in quits for tonight, but if you have more question maybe somebody else will step in, but if not I will be back tomorrow.

  5. #5
    Registered User
    Join Date
    06-21-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Need macro to hide column based on cell value

    Thanks, I'll give it a shot.

    HIDE is populated by a formula. For example, if the period is Jan - June (or 1 thru 6), "HIDE" will be in the cell. If not, it will be blank. I'm trying to simply the process of rolling the schedule forward each month because not all users have the same knowledge of Excel.

    I'll play with what you've given me and post additional questions if I get stumped...which is highly likely!!!

    Thanks for taking the time to help!

    KD

  6. #6
    Forum Contributor
    Join Date
    03-21-2012
    Location
    Ho Chi Minh city
    MS-Off Ver
    Excel 2003
    Posts
    180

    Re: This macro will run faster.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    06-21-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Need macro to hide column based on cell value

    Okay....I got it to hide the column just fine. I suppose I will need the macro to "unhide" the column when the cell value changes back to "blank". This time I've mocked up an example. The yellow fields are the formulas that will determine if the column needs to be hidden. If it says "hide", the macro should hide it. If it is blank, the macro should leave it open and unhide any hidden columns. I tried editing the macro you gave me, but I was just guessing.

    Thanks!
    KD
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    06-21-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: This macro will run faster.

    Thanks Sa DQ,

    I just submitted a post before seeing yours. Thanks for the help! I take a look at it now!

  9. #9
    Registered User
    Join Date
    06-21-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Need macro to hide column based on cell value

    Both macros work to hide the columns based on my criteria, but I suppose I need it to unhide when/if the criteria changes. I'm not familiar enough with what has been given to me to know how to edit it to do the opposite.

    Any guidance is greatly appreciated.

    Thanks!
    KD

  10. #10
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Need macro to hide column based on cell value

    See the attached WorkBook.

    Hope that is what you want
    Attached Files Attached Files
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  11. #11
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Need macro to hide column based on cell value

    Sorry, I sent you Excel 2007 version instead of Excel 2003

    Here you go!
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    06-21-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Need macro to hide column based on cell value

    Thank you very much, Winon. I have just a few newbie questions if you don't mind.

    Dim i As Long and
    Dim LC As Long

    These 2 codes are setting the range, right? Does LC stand for Last Column? Does the i stand for anything or is it just a variable?

    What does Application.ScreenUpdating = False mean?

    Thank you all for your assistance!

    KD

  13. #13
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Need macro to hide column based on cell value

    Hi kduschel,

    You are welcome,

    See this link: http://www.excelforum.com/excel-prog...ens-terms.html

    What does Application.ScreenUpdating = False mean?
    This is used to run the Code "in the background" without the user seeing how things are changing, or sometimes the Sreen "flickers". At the end of the Code the "False" is set to "True". Only then does the screen show you what the Code has done.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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