Hidding Column and Active X CheckBox

menor59

Active Member
Joined
Oct 3, 2008
Messages
495
Hello all,

This code is working..somewhat...When i run the macro to hide the Column and a group of AxtiveX CheckBoxes (there 31 of them) It hides them successfully...But when i run the second macro to unhide...it DOES unHide the column, but i am having to Clidk Design Mode to Show the CHeck Boxes...If you can make the code shorter that would be great! or streamline it. also to add, when the sheet is opened my check boxes arent staying in the Range the are supposed to...they keep shifting to the right...

Any help would be appreciated.


This Code Hides....
Code:
Sub HideU()
Columns("U:U").EntireColumn.Hidden = True
    With ActiveSheet.Shapes("Group 1")
        .GroupItems(1).Visible = True
        .GroupItems(2).Visible = True
        .GroupItems(3).Visible = True
        .GroupItems(4).Visible = True
        .GroupItems(5).Visible = True
        .GroupItems(6).Visible = True
        .GroupItems(7).Visible = True
        .GroupItems(8).Visible = True
        .GroupItems(9).Visible = True
        .GroupItems(10).Visible = True
        .GroupItems(11).Visible = True
        .GroupItems(12).Visible = True
        .GroupItems(13).Visible = True
        .GroupItems(14).Visible = True
        .GroupItems(15).Visible = True
        .GroupItems(16).Visible = True
        .GroupItems(17).Visible = True
        .GroupItems(18).Visible = True
        .GroupItems(19).Visible = True
        .GroupItems(20).Visible = True
        .GroupItems(21).Visible = True
        .GroupItems(22).Visible = True
        .GroupItems(23).Visible = True
        .GroupItems(24).Visible = True
        .GroupItems(25).Visible = True
        .GroupItems(26).Visible = True
        .GroupItems(27).Visible = True
        .GroupItems(28).Visible = True
        .GroupItems(29).Visible = True
        .GroupItems(30).Visible = True
        .GroupItems(31).Visible = True
    End With
End Sub

This Code Unhides...
Code:
Sub UnHideU()
Columns("U:U").EntireColumn.Hidden = False
    With ActiveSheet.Shapes("Group 1")
        .GroupItems(1).Visible = False
        .GroupItems(2).Visible = False
        .GroupItems(3).Visible = False
        .GroupItems(4).Visible = False
        .GroupItems(5).Visible = False
        .GroupItems(6).Visible = False
        .GroupItems(7).Visible = False
        .GroupItems(8).Visible = False
        .GroupItems(9).Visible = False
        .GroupItems(10).Visible = False
        .GroupItems(11).Visible = False
        .GroupItems(12).Visible = False
        .GroupItems(13).Visible = False
        .GroupItems(14).Visible = False
        .GroupItems(15).Visible = False
        .GroupItems(16).Visible = False
        .GroupItems(17).Visible = False
        .GroupItems(18).Visible = False
        .GroupItems(19).Visible = False
        .GroupItems(20).Visible = False
        .GroupItems(21).Visible = False
        .GroupItems(22).Visible = False
        .GroupItems(23).Visible = False
        .GroupItems(24).Visible = False
        .GroupItems(25).Visible = False
        .GroupItems(26).Visible = False
        .GroupItems(27).Visible = False
        .GroupItems(28).Visible = False
        .GroupItems(29).Visible = False
        .GroupItems(30).Visible = False
        .GroupItems(31).Visible = False
    End With
End Sub

Thank you!
 
Last edited:

Some videos you may like

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,406
For your first macro, if you want to hide your checkboxes, you'll need to set the Visible property to False, not True. For your second macro, if you want to unhide your checkboxes, you'll need to set the Visible property to True, not False.

Also, your first macro can be shortened as follows...

Code:
Sub HideU()
    Dim i As Integer
    Columns("U:U").EntireColumn.Hidden = True
    With ActiveSheet.Shapes("Group 1")
        For i = 1 To 31
            .GroupItems(i).Visible = True [COLOR=#008000]'or set to False to hide checkboxes[/COLOR]
        Next i
    End With
End Sub

And, of course, you can do the same sort of thing for your second macro.

Hope this helps!
 
Last edited:

menor59

Active Member
Joined
Oct 3, 2008
Messages
495
ok i did the following..

Code:
Sub HideU()
    Dim i As Integer
    Columns("U:U").EntireColumn.Hidden = True
    With ActiveSheet.Shapes("Group 1")
        For i = 1 To 31
            .GroupItems(i).Visible = True 'or set to False to hide checkboxes
        Next i
    End With
End Sub


Sub UnHideU()
    Dim i As Integer
    Columns("U:U").EntireColumn.Hidden = False
    With ActiveSheet.Shapes("Group 1")
        For i = 1 To 31
            .GroupItems(i).Visible = False 'or set to True to Show checkboxes
        Next i
    End With
End Sub

when i goto Unhide, the Column unhides properly...but the boxes are not "UNhiding", basically i am still having to goto Developer and just single click Design Mode, then the boxes magically appear.
 

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,406
That's because the Visible property for those checkboxes are being set to False in your macro "UnhideU", so you won't see them. Setting Visibility to False makes them invisible, not visible. However, when you click on Design Mode, it makes them available for the user to edit.

In your first macro, you're hiding Column U. Do you then want to hide or make visible your checkboxes???

In your second macro, you're unhiding Column U. Do you then want to make visible or hide your checkboxes???
 

menor59

Active Member
Joined
Oct 3, 2008
Messages
495

ADVERTISEMENT

That's because the Visible property for those checkboxes are being set to False in your macro "UnhideU", so you won't see them. Setting Visibility to False makes them invisible, not visible. However, when you click on Design Mode, it makes them available for the user to edit.

In your first macro, you're hiding Column U. Do you then want to hide or make visible your checkboxes???

In your second macro, you're unhiding Column U. Do you then want to make visible or hide your checkboxes???


Hi,

This Macro Hides Column U and there are 31 Check Boxes That should also be hidden
Code:
Sub HideU()
    Dim i As Integer
    Columns("U:U").EntireColumn.Hidden = True
    With ActiveSheet.Shapes("Group 1")
        For i = 1 To 31
            .GroupItems(i).Visible = True 'or set to False to hide checkboxes
        Next i
    End With
End Sub

This Macro Hoes the opposite for the above, It unhides U and the 31 Check Boxes that are in U
Code:
Sub UnHideU()
    Dim i As Integer
    Columns("U:U").EntireColumn.Hidden = False
    With ActiveSheet.Shapes("Group 1")
        For i = 1 To 31
            .GroupItems(i).Visible = False 'or set to True to Show checkboxes
        Next i
    End With
End Sub

So, the HideU and Check Boxes works perfectly..

When i run the other macro to UNHideU...That works...but the check boxes arent there...i have to just single click design mode to show them again...

I just want to toggle 2 macros...one macro to Hide U and the Boxes group 1
and the other macro to Show U and Boxes in group 1

The boxes in group 1 are Active X Check boxes...31 on them, but i grouped them into 1 group
 
Last edited:

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,406
As I've already mentioned, setting the Visibility property to False makes them invisible, not visible. So your macros should be as follows...

Code:
Sub HideU()
    Dim i As Integer
    Columns("U:U").EntireColumn.Hidden = True
    With ActiveSheet.Shapes("Group 1")
        For i = 1 To 31
            .GroupItems(i).Visible = [COLOR=#ff0000]False[/COLOR]
        Next i
    End With
End Sub


Sub UnHideU()
    Dim i As Integer
    Columns("U:U").EntireColumn.Hidden = False
    With ActiveSheet.Shapes("Group 1")
        For i = 1 To 31
            .GroupItems(i).Visible = [COLOR=#ff0000]True[/COLOR]
        Next i
    End With
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,122,712
Messages
5,597,720
Members
414,168
Latest member
Manapo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top