Multiple Toggle Buttons to hide non-contiguous columns

truebluewoman

New Member
Joined
Sep 26, 2014
Messages
28
I have a workbook that contains several types of R&M that is being performed on living quarters after our residents move out but before a new resident moves into a unit. The units are in rows and the types of work and details are in various columns.

There are about 8 separate types of work, but let's look at two specific ones, Painting and Cleaning.

Painting:
Columns U:Y and AE are the columns that we want to see when we click on the ToggleButton2. I named a range called ASSIGN_PT that contains everything that I want hidden EXCEPT those particular columns.

Cleaning:
Columns AF:AJ and AN are the columns that we want to see when we click on ToggleButton3. I named a range called ASSIGN_CLN that contains everything that I want hidden EXCEPT those particular columns.

I have two separate toggle buttons with the following code:

VBA Code:
Private Sub ToggleButton2_Click()

If ToggleButton2.Value = True Then
    
Sheets("6 - Contractor Schedule").Range("ASSIGN_PT").EntireColumn.Hidden = True

ElseIf ToggleButton2.Value = False Then
    
Range("ASSIGN_PT").EntireColumn.Hidden = False
    
End If

End Sub

Private Sub ToggleButton3_Click()

If ToggleButton3.Value = True Then
    
Sheets("6 - Contractor Schedule").Range("ASSIGN_CLN").EntireColumn.Hidden = True

ElseIf ToggleButton3.Value = False Then
    
Range("ASSIGN_CLN").Columns.EntireColumn.Hidden = False
    
End If

End Sub

It worked fine when I added the first toggle button, but when I added the second one, the first one stopped being able to be clicked at all. Then I added a third one and the second one stopped working. I've gone in and out of design mode, so I know that's not it.

Now that I added the 3rd Toggle button, when I click on the toggle button 2, it just doesn't "depress" at all and I'm not sure why. It is not a protected workbook. I've added a couple of screenshots that shows what happens when I click on ToggleButton3 and another that shows what happens when I click on Toggle Button 2 (View Paint Assignments). I'm not sure what I am doing wrong, but I'm hoping that someone here can help me out. Thanks, in advance!
 

Attachments

  • Toggle Button 3.JPG
    Toggle Button 3.JPG
    36.8 KB · Views: 4
  • Toggle Button 2.JPG
    Toggle Button 2.JPG
    61 KB · Views: 4

Some videos you may like

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

steve the fish

Well-known Member
Joined
Oct 20, 2009
Messages
8,387
Office Version
  1. 365
Platform
  1. Windows
If you want to toggle use an equal and opposite action such as:

VBA Code:
Private Sub ToggleButton1_Click()

Range("ASSIGN_PT").EntireColumn.Hidden = Not Range("ASSIGN_PT").EntireColumn.Hidden

End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,127,359
Messages
5,624,234
Members
416,017
Latest member
moritz210

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