+ Reply to Thread
Results 1 to 6 of 6

Hide/Unhide an indirectly referenced column

  1. #1
    Registered User
    Join Date
    10-24-2012
    Location
    San Jose, CA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Hide/Unhide an indirectly referenced column

    I want to automatically hide/unide columns in a worksheet based on the contents of a cell. The cell contains the name of the column that should be hidden. Using the following VBA code, I can get the unhide/hide to work fine, but not sure on how to reference the contents of the cell instead of hardcoding the column to hide/unhide.

    The column that I want to hide is defined in cell B12. The contents of cell B12 is currently something like "F" to indicate column F.

    Can someone help?

    Please Login or Register  to view this content.

    Moderator Edit:

    Welcome to the forum, Aegwyn11.

    Please notice that [CODE] tags have been added to your post. The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at the top of the page and read Rule #3.
    Thanks.
    Last edited by Cutter; 10-27-2012 at 05:16 PM. Reason: Added code tags

  2. #2
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    818

    Re: Hide/Unhide an indirectly referenced column

    Please Login or Register  to view this content.
    Or:
    Please Login or Register  to view this content.
    Last edited by HSV; 10-27-2012 at 02:35 PM.
    Kind regards, Harry.

  3. #3
    Registered User
    Join Date
    10-24-2012
    Location
    San Jose, CA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Hide/Unhide an indirectly referenced column

    Harry,

    Thanks for catching my spelling error...I never was good at spelling in grade school.

    Your solution seems simple and easy, except that I don't think it would work for columns beyond Z (AA+). This must be able to support multi-letter columns.

    Thanks.

  4. #4
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    818

    Re: Hide/Unhide an indirectly referenced column

    Maybe this is better.
    Please Login or Register  to view this content.
    Or:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-24-2012
    Location
    San Jose, CA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Hide/Unhide an indirectly referenced column

    Okay got it. Harry's code above didn't quite work, but came close (and cleans up the code quite a bit, thanks). Here's the working code.

    Please Login or Register  to view this content.
    My next problem is getting this function to kick off when the value in the target cell changes as a result of a recalculation caused by an action on another sheet, but I'm pretty sure I saw something for that when searching for something a few days ago.

  6. #6
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    818

    Re: Hide/Unhide an indirectly referenced column

    Upload your file to share it with the helpers.

+ 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