+ Reply to Thread
Results 1 to 4 of 4

Hiding columns based on a header value

Hybrid View

numbers2 Hiding columns based on a... 05-24-2012, 04:39 PM
Pichingualas Re: Hiding columns based on a... 05-24-2012, 04:54 PM
numbers2 Re: Hiding columns based on a... 05-24-2012, 09:08 PM
aussieboykie Re: Hiding columns based on a... 05-24-2012, 10:16 PM
  1. #1
    Registered User
    Join Date
    05-24-2012
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Hiding columns based on a header value

    Hello All,


    I am looking for a formula or macro that will hide multiple columns in an excel worksheet based on the value in the Header of the worksheet?

  2. #2
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: Hiding columns based on a header value

    OK, how exactly. Do you want it to hide the columns that match the text in the header? (I assume you are talking about the header from when you print the page and not the value in the first row of each column)
    .?*??)
    `?.???.?*??)?.?*?)
    (?.?? (?.?
    Pichingualas <---
    ??????????????????????????

    Wrap your code with CODE TAGS.
    Thank those who helped you, Don't forget to add to their REPUTATION!!! (click on the star below their post).
    Please mark your threads as [SOLVED] when they are (Thread Tools->Mark thread as Solved).

  3. #3
    Registered User
    Join Date
    05-24-2012
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Hiding columns based on a header value

    No I am referring to the values in Row 1. Is this possible to do in Excel 2003?

  4. #4
    Registered User
    Join Date
    11-08-2006
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    37

    Re: Hiding columns based on a header value

    This code will let you toggle column hide/show according to the label in row 1.
    Function ToggleHideCol(Lbl As String) As Range
        Set ToggleHideCol = Rows(1).Find(what:=Lbl, LookIn:=xlFormulas, lookat:=xlWhole)
        If Not ToggleHideCol Is Nothing Then ToggleHideCol.EntireColumn.Hidden = Not ToggleHideCol.EntireColumn.Hidden
    End Function
    
    Sub ToggleHide()
        Dim c As Range
        Dim s As String
        s = InputBox("Enter a label to find", "Toggle Hide by Label")
        If Not s = "" Then
            Set c = ToggleHideCol(Lbl:=s)
            If c Is Nothing Then Call MsgBox("Label """ & s & """ not found.")
        End If
    End Sub
    Regards, AB

+ 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