+ Reply to Thread
Results 1 to 11 of 11

Hide multiple checkboxes when a row is hidden

Hybrid View

  1. #1
    Registered User
    Join Date
    09-06-2013
    Location
    santiago
    MS-Off Ver
    Excel 2007
    Posts
    15

    Question Hide multiple checkboxes when a row is hidden

    Hello Hello,

    I am using 5 option buttons to hide columns D, E, F, G, H respectively. What i am trying to achieve is that if option button 1 is selected, only column D appears - containing multiple Checkboxes. When option button 2 is selected, only column E appears, containing multiple checkboxes (different from those in the previous column) and so on and so on...

    I managed to hide/unhide the columns, the problem i am facing now is that the chceckboxes "float" and never dissapear. At the moment i am using this (for option button 1 & column D):

    Sub uno()
    '
    ' uno Macro
    ' uno
    '
    ' Keyboard Shortcut: Ctrl+u
    '
    Columns("E:H").Select
    Range("H1").Activate
    Selection.EntireColumn.Hidden = True
    ActiveWindow.ScrollColumn = 3
    ActiveWindow.ScrollColumn = 2
    ActiveWindow.ScrollColumn = 1
    Columns("D:D").Select
    Selection.EntireColumn.Hidden = False
    Range("D12").Select
    End Sub

    I am very very new at this, is there anything i can add to this to make the checkboxes hide/unhide together with the columns? Or do i need to change the whole thing? I wouldn't be surprised if there was a better option...

    many many thanks in advance ,
    regards,
    dana

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Hide multiple checkboxes when a row is hidden

    I'd guess you could do something like:
    Sub hide_unhide_checkboxes()
    Dim chkbx
    For Each chkbx In ActiveSheet.CheckBoxes
        If Columns(chkbx.TopLeftCell.Column).Hidden = True Then chkbx.Visible = False Else chkbx.Visible = True
    Next
    End Sub

  3. #3
    Registered User
    Join Date
    09-06-2013
    Location
    santiago
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Hide multiple checkboxes when a row is hidden

    I might be doing it wrong, but it doesn't seem to work

    I attach the .xls, any suggestion i can do?
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Hide multiple checkboxes when a row is hidden

    I think it didn't work because all the checkboxes started in column C, if you unhide all the columns and then move them all slightly right so they are completely within column D it should work ok.

  5. #5
    Registered User
    Join Date
    09-06-2013
    Location
    santiago
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Hide multiple checkboxes when a row is hidden

    ok, i moved them completely to column D. Do i assign the code to one of the chcekboxes or where do i paste it? i am sorry, i am very new to this.

    many thanks for your help Yudlugar

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Hide multiple checkboxes when a row is hidden

    Your module should be something like:
    Sub uno()
    '
    ' uno Macro
    ' uno
    '
    ' Keyboard Shortcut: Ctrl+u
    '
    Columns("E:H").Select
    Range("H1").Activate
    Selection.EntireColumn.Hidden = True
    ActiveWindow.ScrollColumn = 3
    ActiveWindow.ScrollColumn = 2
    ActiveWindow.ScrollColumn = 1
    Columns("D:D").Select
    Selection.EntireColumn.Hidden = False
    Range("D12").Select
    call hide_unhide_checkboxes
    End Sub
    
    Sub hide_unhide_checkboxes()
    Dim chkbx
    For Each chkbx In ActiveSheet.CheckBoxes
        If Columns(chkbx.TopLeftCell.Column).Hidden = True Then chkbx.Visible = False Else chkbx.Visible = True
    Next
    End Sub

  7. #7
    Registered User
    Join Date
    09-06-2013
    Location
    santiago
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Hide multiple checkboxes when a row is hidden

    Many thanks Yudlugar,

    you are a genius this worked... the checkboxes move according to the column in shich they appear. The problem is that they don't hide/unhide, instead they just appear on top of each other. How to make them hide/unhide please ?
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Hide multiple checkboxes when a row is hidden

    It might be best to try unhiding/hiding them before you hide the columns. It seems you can get it to work providing that you have them set up in precisely the right location, it should be more forgiving the other way:

    Sub tres()
    '
    ' tres Macro
    ' 3
    '
    ' Keyboard Shortcut: Ctrl+t
    '
    Dim chkbx
        Columns("A:H").Hidden = False
    For Each chkbx In ActiveSheet.CheckBoxes
        chkbx.Visible = False
    Next chkbx
    Call hide_unhide_checkboxes(4)
    Call hide_unhide_checkboxes(5)
    Call hide_unhide_checkboxes(7)
    Call hide_unhide_checkboxes(8)
    Range("D1:E1,G1:H1").EntireColumn.Hidden = True
    
    End Sub
    Sub cuatro()
    '
    ' cuatro Macro
    ' 4
    '
    ' Keyboard Shortcut: Ctrl+c
    '
    Dim chkbx
        Columns("A:H").Hidden = False
    For Each chkbx In ActiveSheet.CheckBoxes
        chkbx.Visible = False
    Next chkbx
    Call hide_unhide_checkboxes(4)
    Call hide_unhide_checkboxes(5)
    Call hide_unhide_checkboxes(6)
    Call hide_unhide_checkboxes(8)
    Range("D1,F1:H1").EntireColumn.Hidden = True
    
    End Sub
    Sub pat()
    '
    ' pat Macro
    ' 5
    '
    ' Keyboard Shortcut: Ctrl+p
    '
    Dim chkbx
        Columns("A:H").Hidden = False
    For Each chkbx In ActiveSheet.CheckBoxes
        chkbx.Visible = False
    Next chkbx
    Call hide_unhide_checkboxes(4)
    Call hide_unhide_checkboxes(5)
    Call hide_unhide_checkboxes(6)
    Call hide_unhide_checkboxes(7)
    Range("D1:G1").EntireColumn.Hidden = True
    
    End Sub
    Sub uno()
    '
    ' uno Macro
    ' uno
    '
    ' Keyboard Shortcut: Ctrl+u
    '
    Dim chkbx
        Columns("A:H").Hidden = False
    For Each chkbx In ActiveSheet.CheckBoxes
        chkbx.Visible = False
    Next chkbx
    Call hide_unhide_checkboxes(5)
    Call hide_unhide_checkboxes(6)
    Call hide_unhide_checkboxes(7)
    Call hide_unhide_checkboxes(8)
    Range("E1:H1").EntireColumn.Hidden = True
    
    End Sub
    Sub dos()
    '
    ' dos Macro
    ' 2
    '
    ' Keyboard Shortcut: Ctrl+d
    '
    Dim chkbx
        Columns("A:H").Hidden = False
    For Each chkbx In ActiveSheet.CheckBoxes
        chkbx.Visible = False
    Next chkbx
    Call hide_unhide_checkboxes(4)
    Call hide_unhide_checkboxes(6)
    Call hide_unhide_checkboxes(7)
    Call hide_unhide_checkboxes(8)
    Range("D1,F1:H1").EntireColumn.Hidden = True
    End Sub
    Sub hide_unhide_checkboxes(col_num As Integer)
    Dim chkbx
    For Each chkbx In ActiveSheet.CheckBoxes
        If chkbx.TopLeftCell.Column = col_num Then chkbx.Visible = False Else chkbx.Visible = True
    Next
    End Sub

  9. #9
    Registered User
    Join Date
    09-06-2013
    Location
    santiago
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Hide multiple checkboxes when a row is hidden

    can't get it going...it doesn't seem to have chenged from the previous code, checkboxes covering each other ...for some reason some checkboxes appear in the column I (9), i don't understand why.
    Last edited by daniva92; 09-09-2013 at 01:52 PM.

  10. #10
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Hide multiple checkboxes when a row is hidden

    Sorry, I think you will need to approach it with a different method then, it worked ok for me.

  11. #11
    Registered User
    Join Date
    09-06-2013
    Location
    santiago
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Hide multiple checkboxes when a row is hidden

    i used Form Control Checboxes, which might have been a problem. Changen them to ActiveX Controls, everything works..."Like a Boss".

    Many thanks for your help and pacience Yudlugar, you are a hero.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Hide a many checkboxes when the column is hidden
    By Gruberj01 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-11-2013, 06:15 AM
  2. need macro to hide/unhide columns through multiple checkboxes
    By trier in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-31-2013, 04:00 PM
  3. Show/Hide Range of Cells Using Multiple Checkboxes
    By rdacso in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-21-2013, 02:06 PM
  4. Using multiple checkboxes as an index page to hide/unhide worksheets
    By Damien_Lee in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-11-2013, 07:24 AM
  5. Hide/Unhide Multiple Checkboxes
    By LampCommandr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2011, 09:35 AM

Tags for this Thread

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