Hidding Column and Active X CheckBox

menor59

Well-known Member
Joined
Oct 3, 2008
Messages
570
Office Version
  1. 2021
Platform
  1. Windows
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:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
20,216
Office Version
  1. 365
Platform
  1. Windows
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

Well-known Member
Joined
Oct 3, 2008
Messages
570
Office Version
  1. 2021
Platform
  1. Windows
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
20,216
Office Version
  1. 365
Platform
  1. Windows
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

Well-known Member
Joined
Oct 3, 2008
Messages
570
Office Version
  1. 2021
Platform
  1. Windows

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
20,216
Office Version
  1. 365
Platform
  1. Windows
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
 

menor59

Well-known Member
Joined
Oct 3, 2008
Messages
570
Office Version
  1. 2021
Platform
  1. Windows
augh man!!!! ugh...how did i miss that...
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,766
Messages
5,833,578
Members
430,221
Latest member
pgn29

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