Results 1 to 3 of 3

Thread: hide columns

  1. #1
    Board Regular
    Join Date
    Oct 2012
    Posts
    149
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default hide columns

    hi all

    I haven't found anything yet that can help me do what i need. Hoping someone may have the answer.

    I have B11 setup with a drop down list of peoples names.
    In range D11:IS11 are those same names.

    i would like a macro that searches D11:IS11 for the name in B11 and if it is found, hide all other columns.

    preference would be that the macro runs from clicking a 'search' button, not by worksheet change event

    TIA

  2. #2
    Board Regular alansidman's Avatar
    Join Date
    Feb 2007
    Location
    Steamboat Springs
    Posts
    4,929
    Post Thanks / Like
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)

    Default Re: hide columns

    Here is the code you need to attach to a button

    Code:
    Option Explicit
    
    
    Sub HideB11()
        Dim i As Long
        Application.ScreenUpdating = False
        For i = 4 To 253
            If Cells(11, i) <> Range("B11") Then
                Cells(11, i).EntireColumn.Hidden = True
            End If
        Next i
        Application.ScreenUpdating = True
    
    
    End Sub
    Let me know if that works for you
    Alan

    Am Yisrael Chai

    Win 10--Office 2019
    When Posting Code, please use code tags.
    How to insert Mcode to Power Query https://excel.solutions/2017/11/powe...te-code-video/


  3. #3
    Board Regular
    Join Date
    Oct 2012
    Posts
    149
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: hide columns

    that is spot on, i appreciate your fast reply.

    thank you very much

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •