gobblechops

New Member
Joined
Apr 27, 2017
Messages
26
Hi,

Below is some VBA code used with a toggle button to hide/unhide rows 8:10. This works perfectly.

I need to amend the code so the button hides/unhides rows 16,22,23,26,30,32,46,49,52,55,58 AND Columns G,H,I,J.

Private Sub ToggleButton1_Click()
Dim xAddress As String
xAddress = "8:10"
If ToggleButton1.Value Then
Application.ActiveSheet.Rows(xAddress).Hidden = True
ToggleButton1.Caption = "Show Scenario"
Else
Application.ActiveSheet.Rows(xAddress).Hidden = False
ToggleButton1.Caption = "Hide Scenario"
End If
End Sub

Thanks in advance.
 

Some videos you may like

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
6,484
Office Version
  1. 2019
Platform
  1. Windows
Hi,
untested

Code:
Private Sub ToggleButton1_Click()
    Range("G:J").EntireColumn.Hidden = ToggleButton1.Value
    Range("8:10,16:16,22:23,26:26,30:30,32:32,46:46,49:49,52:52,55:55,58:58").EntireRow.Hidden = ToggleButton1.Value
    ToggleButton1.Caption = IIf(ToggleButton1.Value, "Show Scenario", "Hide Scenario")
End Sub

Dave
 

Watch MrExcel Video

Forum statistics

Threads
1,127,542
Messages
5,625,416
Members
416,101
Latest member
CCoetzee

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