Results 1 to 6 of 6

Hide/Unhide an indirectly referenced column

Threaded View

  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?

    Option Explicit
     
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        Set Target = Range("B13")
        Select Case Target.Value
        Case "Visable"
            Worksheets("VQ").Columns("F:F").EntireColumn.Hidden = False
        Case "Hidden"
            Worksheets("VQ").Columns("F:F").EntireColumn.Hidden = True
        Case Else
            Exit Sub
        End Select
    
    End Sub

    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

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