Hide/Unhide Button

young engineer

Board Regular
Joined
Mar 3, 2009
Messages
100
Hi All

I want to create a button to hide and unhide columns F,G,J,K,M,N,P,Q,R,S,T in my worksheet. I want to create a single button to display "Hide Columns" and Unhide Columns"

Any help will be appreciated
Thanks
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Code:
    With Columns("F:T")
    
        .Hidden = Not .Hidden
    End With
    Columns("H:I").Hidden = False
    Columns("L").Hidden = False
    Columns("O").Hidden = False
 
Upvote 0
Add a toggle button to your sheet. Right click it and select "view code" then paste the following code within the click event:


Code:
    Dim bool As Boolean
    bool = ToggleButton1.Value
        If bool Then
            ToggleButton1.Caption = "Show Columns"
        Else
            ToggleButton1.Caption = "Hide Columns"
        End If
    Columns("F:F").EntireColumn.Hidden = bool
    Columns("g:g").EntireColumn.Hidden = bool
    Columns("j:k").EntireColumn.Hidden = bool
    Columns("m:n").EntireColumn.Hidden = bool
    Columns("p:p").EntireColumn.Hidden = bool
    Columns("q:t").EntireColumn.Hidden = bool



Brian
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

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