Code for Hiding / unhiding columns using Active X Control Checkbox

davidfrommke

New Member
Joined
Sep 16, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hello all -

I am in need of assistance.
What I am trying to do is create a code where I click on a checkbox using an Active X Control Checkbox and it only displays information in that column.
For example, if my spreadsheet has "GM", I click the check box and the only column that appears is "GM" and all the others are hidden.

The problem I am having is when the checkbox is not checked, it shows that particular column.

Here is the code I am using -
VBA Code:
Private Sub CheckBox2_Click()
    [k:bc].EntireColumn.Hidden = Not CheckBox2
End Sub

I know it is something simple, which means I cannot recall what it is.

And as long as I have you, what would the code be in this situation.

I want to only show one column. But I need the columns before a particular column and after to be hidden.

Thanks in advance for your assistance.

Dave

Also asked here Active X Control Checkbox to hide columns when checked
 
Last edited by a moderator:

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,224,814
Messages
6,181,120
Members
453,021
Latest member
Justyna P

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