+ Reply to Thread
Results 1 to 10 of 10

Hide & Unhide columns based on a cell value

  1. #1
    Registered User
    Join Date
    02-21-2010
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    40

    Talking Hide & Unhide columns based on a cell value

    Hello everyone,

    I have a particular problem with a worksheet I am working on at the moment, basically if row 5 has a 0 displayed I want that column to hide, but if row 5 has text of any value displayed I want it to unhide, the range is E5 to BA5 across.

    I have draft VBA code as follows:

    Please Login or Register  to view this content.
    This works to an extent in that it will hide the columns with the 0 displayed, but when I unhide them the word TRUE is input in other blank cells, and also if text is input for the hidden rows they do not unhide...
    Last edited by teylyn; 02-21-2010 at 06:52 AM. Reason: changed quote to code tags

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Hide & Unhide columns based on a cell value

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    Replace the Color Tags with Code Tags
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    02-21-2010
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    40

    Re: Hide & Unhide columns based on a cell value

    sorry, I have amended as instructed...

    Any thoughts re my original post?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Hide & Unhide columns based on a cell value

    Thanks for taking the time to read and comply with the rule .

    Your question says the cell contains 0,but the code looks for "Hide Column"

  5. #5
    Registered User
    Join Date
    02-21-2010
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    40

    Re: Hide & Unhide columns based on a cell value

    sorry the hide column is incorrect this should say 0 in my original post

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Hide & Unhide columns based on a cell value

    If the cells contain zero then this should work
    Please Login or Register  to view this content.
    Note you do not restore calculation in your code

    To change the code to unhide change to this line
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-21-2010
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    40

    Re: Hide & Unhide columns based on a cell value

    Thanks Roy, this works to hide the cells with a 0 displayed, but how do I incorporate a function within the code to unhide the particular columns if text is displayed in the same row.

    e.g. if E3 says 0 column E hides, but if it says David, or Steve I want it to Unhide and reveal

    Appreciated

    Thanks
    David

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Hide & Unhide columns based on a cell value

    You didn't mention that, try
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-21-2010
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    40

    Thumbs up Re: Hide & Unhide columns based on a cell value

    Excellent thanks Roy works great

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Hide & Unhide columns based on a cell value

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

    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

+ 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