hi.
yes. and you can also make it boolen in a way.
cb1 = alias for commandbutton1. just change button name. saves a lot of
typing.
Private Sub cb1_Click()
If Rows("20:24").Hidden = True Then
Rows("20:24").Hidden = False
cb1.BackColor = RGB(0, 0, 255) 'Change button color
cb1.Caption = "Hide" 'change button caption
Else
If Rows("20:24").Hidden = False Then
Rows("20:24").Hidden = True
cb1.BackColor = RGB(245, 30, 5)
cb1.Caption = "UnHide"
End If
End If
End Sub
Sub Demo2()
With Range("4:380").EntireRow
.Hidden = Not .Hidden
End With
'But these are always visible...
Range("A35,A65,A97,A128,A160,A191,A223,A255,A286,A318,A349"). _
EntireRow.Hidden = False
End Sub
hi,
references to the button have to be outside of the with clause because the
with range clasue references a range. to reference the button, start another
with clause. and you will need an if statement to test if the rows are hidden
or not.
Private Sub CB5_Click()
If Rows("21:22").EntireRow.Hidden = True Then
With CB5
.BackColor = RGB(0, 0, 255)
.Caption = "Hide"
.ForeColor = RGB(245, 245, 6)
End With
Else
With CB5
.BackColor = RGB(244, 7, 6)
.Caption = "UnHide"
.ForeColor = RGB(1, 1, 1)
End With
End If
With Range("21:22").EntireRow
.Hidden = Not .Hidden
End With
End Sub
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.