Forum Discussion
rbalza
Jul 08, 2021Brass Contributor
Toggle (Show / Hide) rows
Hi Everyone, Would like to know, how to create a toggle button in which it will show or hide a set of rows similar to below:
rbalza
Jul 08, 2021Brass Contributor
Hi, apologies for not being clear. It is something like a button. I used vba however, is there anyway like it is using a cell itself not a button? Here's my code.
Private Sub ToggleButton1_Click()
Dim xCells As String
xCells = "1:15" 'change this to the row numbers
If ToggleButton1.Value Then
Application.ActiveSheet.Rows(xCells).Hidden = "True"
ToggleButton1.Caption = "+"
Else
Application.ActiveSheet.Rows(xCells).Hidden = "False"
ToggleButton1.Caption = "-"
End If
End Sub
Private Sub ToggleButton1_Click()
Dim xCells As String
xCells = "1:15" 'change this to the row numbers
If ToggleButton1.Value Then
Application.ActiveSheet.Rows(xCells).Hidden = "True"
ToggleButton1.Caption = "+"
Else
Application.ActiveSheet.Rows(xCells).Hidden = "False"
ToggleButton1.Caption = "-"
End If
End Sub
Subodh_Tiwari_sktneer
Jul 08, 2021Silver Contributor
Why not upload a sample file to know what you already have and what exactly you are trying to achieve? Don't forget to add the comments in the file itself to describe the end result you are trying to achieve.