Toggle button Macro

gobblechops

New Member
Joined
Apr 27, 2017
Messages
24
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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
5,910
Office Version
2019
Platform
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,101,904
Messages
5,483,639
Members
407,400
Latest member
Rakeforms

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top