+ Reply to Thread
Results 1 to 8 of 8

Hide a many checkboxes when the column is hidden

  1. #1
    Registered User
    Join Date
    05-08-2013
    Location
    Long Island, NY
    MS-Off Ver
    Excel 2007
    Posts
    4

    Hide a many checkboxes when the column is hidden

    Hello.

    I am using a macro to hide a column. The macro works fine. In the column I have about 20 checkboxs. I would like the checkboxes to be hidden also when the column is hidden. Below is the macro I am using. Does anyone know what I can add to this macro to make the checkboxes hide.

    I am new at this.. thank you...

    John


    Sub HideColsProjectCost()
    Dim cl As Range
    For Each cl In Sheets("Project Cost").Range("$AC$1")
    If UCase(cl) = "1" Then
    cl.EntireColumn.Hidden = True

    Else: cl.EntireColumn.Hidden = False
    End If
    Next cl
    End Sub

  2. #2
    Forum Contributor ragavan.sridar1's Avatar
    Join Date
    11-19-2012
    Location
    India
    MS-Off Ver
    Excel 2010, Excel 2003
    Posts
    208

    Re: Hide a many checkboxes when the column is hidden

    Please Login or Register  to view this content.
    this will hide all the checkboxes in the sheet.
    Thanks!
    Raga.

    Please,mark your thread [SOLVED] if you received your answer.

    Click the little star * below, to give some Rep if you think an answer deserves it.

    I learnt so many things from these links.

  3. #3
    Registered User
    Join Date
    05-08-2013
    Location
    Long Island, NY
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Hide a many checkboxes when the column is hidden

    Hi Raga,

    Thank you for your help..

    I have checkboxs in another column in the same worksheet that I do not want to hide. Is there a way to only hide the checkboxes in the column that is hidden and leave the other set of checkboxes on the worksheet.

    Thank you
    John

  4. #4
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Hide a many checkboxes when the column is hidden

    As range "AC1" is only one cell you do not need to loop.
    Also if you hide the column "AC" you will not see the value "1", in order to change it, so the code below will hide the column "AC" with its Controls if cell "AD1" = "1" and un-hide it if you run the code again when it is <> "1"
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-08-2013
    Location
    Long Island, NY
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Hide a many checkboxes when the column is hidden

    Hi Mick G,

    Thank you that works..

    I would also like to hide the next two columns as well AD and AE. But when I change the code Range from ("$AC$1) to ("$AC$1:$AE$1") a error occurs in the next line.

    If cl.Offset(, 2).Value = "1" Then

    Do you have any recommendations on how to make this work..

    Thank you

  6. #6
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Hide a many checkboxes when the column is hidden

    Place you number in cell "AB1" and alter the code in RED as below:-
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-08-2013
    Location
    Long Island, NY
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Hide a many checkboxes when the column is hidden

    Hi Mick G,

    Thank you. That worked Great. One more question. Is it possible to hide two columns to the left as well? AB and AA.

    Thank you
    John

  8. #8
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Hide a many checkboxes when the column is hidden

    Change the following lines (in Red)
    NB:- the "1" value is now in "Z1"
    Please Login or Register  to view this content.

+ 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