Microsoft Office Tutorials and References
In Depth Information
‘Toggle between views based on the button’s captions
‘to determine which view is next in the cycle.
If .Caption = “SHOW ALL” Then
.EntireColumn.Hidden = False
.EntireRow.Hidden = False
.Caption = “MONTH TOTALS”
ElseIf .Caption = “MONTH TOTALS” Then
Range(“B:F”).EntireColumn.Hidden = True
.Caption = “ITEM TOTALS”
ElseIf .Caption = “ITEM TOTALS” Then
Range(“B:F”).EntireColumn.Hidden = False
Rows(“6:17”).Hidden = True
.Caption = “SHOW ALL”
End If ‘for evaluating the button caption.
‘Close the With structure for Application.Caller.
‘Turn ScreenUpdating on again.
Application.ScreenUpdating = True
Press Alt+Q to return to the worksheet.
Draw a Forms button onto your worksheet at the top of column A. When you release the
mouse button you’ll see the Assign Macro dialog box. Select the macro named ToggleViews
and click the OK button as shown in Figure 13-24.