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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

xld

Banned
Joined
Feb 8, 2003
Messages
5,378
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

micro-blades

Board Regular
Joined
Feb 20, 2007
Messages
91
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,191,578
Messages
5,987,416
Members
440,096
Latest member
yanaungmyint

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