Toggle Button Caption
Here's your code modified
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim I As Long
Dim Hidden As Boolean
For I = 8 To 426
If Rows(I).EntireRow.Hidden Then
Hidden = True
Rows(I).EntireRow.Hidden = False
CommandButton1.Caption = "Hide"
End If
Next I
If Hidden Then Exit Sub
For I = 8 To 426
If Cells(I, 2).Value < "TOTAL" Then
Range(Cells(I, 1), Cells(I, 1)).EntireRow.Hidden = True
CommandButton1.Caption = "Show"
End If
Next I
End Sub
Sandy
Al wrote:
Hi Guys
I have the following code which hides/unhides rows, that I have assigned to
a button...
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Dim I As Long
Dim Hidden As Boolean
For I = 8 To 426
If Rows(I).EntireRow.Hidden Then
Hidden = True
Rows(I).EntireRow.Hidden = False
End If
Next I
If Hidden Then Exit Sub
For I = 8 To 426
If Cells(I, 2).Value < "TOTAL" Then
Range(Cells(I, 1), Cells(I, 1)).EntireRow.Hidden = True
End If
Next I
End Sub
... how do I toggle the button caption so that when that only the TOTAL rows
are showing the caption is SHOW and else the caption is HIDE?
Thanks!
|