multiple checkboxes with multiple hidden columns

MickJacko

New Member
Joined
Dec 16, 2009
Messages
9
Hi there - thanks for your time in advance. :)

I am trying to create a report from excel that does the following:

i have my checkboxes in sheet 1, and i want to hide various columns if the checkbox is not selected in sheet 2. each checkbox is directly related to a column in sheet 2.

example:
In sheet 1, I have 5 check boxes labeled:
checkbox 1
checkbox 2
checkbox 3
checkbox 4
checkbox 5

i want to create any combination of the following:
when i tick checkbox 1, column A in sheet 2 is shown
when i do not tick checkbox 2, column B in sheet 2 is not shown
when i tick checkbox 3, column C in sheet 2 is shown
when i do not tick checkbox 4, column D in sheet 2 is not shown
when i tick checkbox 5, column D in sheet 2 is shown

Any help would be greatly appreciated to get this complete.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi,

Using ActiveX checkboxes, you can do the following:

Once you have your checkboxes, double click when in design mode and Type in the following in between Private Sub and End Sub.

Application.ScreenUpdating = False
If checkbox1.Value = True Then
Sheet2.Select
Sheet2.Columns("A:A").Select
Selection.EntireColumn.Hidden = False
Elseif Checkbox1.Value = False Then
Sheet2.Select
Sheet2.Columns("A:A").Select
Selection.EntireColumn.Hidden = True
End If
Sheet1.Select
Application.ScreenUpdating = True

For Checkbox2
Application.ScreenUpdating = False
If checkbox2.Value = True Then
Sheet2.Select
Sheet2.Columns("B:B").Select
Selection.EntireColumn.Hidden = False
Elseif Checkbox2.Value = False Then
Sheet2.Select
Sheet2.Columns("B:B").Select
Selection.EntireColumn.Hidden = True
End If
Sheet1.Select
Application.ScreenUpdating = True

Follow the same logic for Checkbox3, changing the column to "C"

For Checkbox4

Application.ScreenUpdating = False
If (Checkbox4.Value = True And Checkbox5.Value = False) Then
Sheet2.Select
Sheet2.Columns("D:D").Select
Selection.EntireColumn.Hidden = False
ElseIf (Checkbox4.Value = True And Checkbox5.Value = True) Then
Sheet2.Select
Sheet2.Columns("D:D").Select
Selection.EntireColumn.Hidden = True
ElseIf (Checkbox4.Value = False And Checkbox5.Value = True) Then
Sheet2.Select
Sheet2.Columns("D:D").Select
Selection.EntireColumn.Hidden = True
End If
Sheet1.Select
Application.ScreenUpdating = True

Use the same Code from checkbox4 in checkbox5

Nuc
 
Upvote 0
Thanks nuc_n_futs - like the nickname!!

Still having issues with it.

Is it possible for you to place it in an excel file and send to me?

Regards,
 
Upvote 0
Another approach would be to use checkboxes from the Forms menu and assign all of them to this macro.

Code:
Sub CheckControlColumnVisiblity()
    Dim boxIndex As Long
    boxIndex = Right(Application.Caller, 1)
    With ActiveSheet
        .Columns(Val(Right(Application.Caller, 1))).EntireColumn.Hidden = (.Shapes(Application.Caller).ControlFormat.Value = xlOff)
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

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
Back
Top