Databases Reference
In-Depth Information
1.
The appropriate Columns (“E:L”) must be hidden.
2.
The Header must be reformatted.
3.
The Quiz Grades must be calculated (they may have been modified when all the columns
were shown!).
4.
The button caption should be changed to: “Quiz Grades Hidden.”
5.
The position of the print button must be moved (to the left).
Similarly, when transitioning from Figure 6.4 to Figure 6.3, the following steps must be taken.
1.
The appropriate Columns (“E:L”) must be unhidden or made visible.
2.
The Header must be reformatted.
3.
The button caption should be changed to: “Quiz Grades Shown.”
4.
The position of the print button must be moved (to the right).
These steps are taken when the “Quiz Grades Shown/Quiz Grades Hidden” button is pressed.
The caption may change, but the button executes the same VBA code no matter which caption is
shown. Note that the button merely toggles state (and Worksheet view) with each push.
Private Sub Hide_Button_Click()
Select Case Hide_Button.Value
Case True
'Show All Columns (Columns Hidden @ Start)
Columns("E:L").Select
Selection.EntireColumn.Hidden = False
'This Copies the whole Header over
Call CopySection
(ActiveWorkbook.Name, "HdrVisible", 1, 1,
7, 20, ActiveWorkbook.Name, ActiveSheet.Name, 1, 1)
Print_Button.Left = 641.25
Hide_Button.Caption = "Quiz Grades Shown"
Case False
'Hide Columns with Extraneous Info (QUIZ GRADES)
'(All Columns All Shown @ Start)
'Unhide Columns
Call ClearUnHiddenRange(ActiveSheet.Name, 7, 15)
Call HideColRange("F:K")
'This Copies the whole Header over
(ActiveWorkbook.Name, "HdrHidden",
1, 1, 7, 20, ActiveWorkbook.Name, ActiveSheet.Name, 1, 1)
Call CopySection
Print_Button.Left = 631.25
Hide_Button.Caption = "Quiz Grades Hidden"
Call CalcQuizAvg
End Select
End Sub
The code for the button just given actually resides within the Worksheet object itself — in this
case the “ClassGrades” Worksheet. Up until now, all VBA code has either resided within a module
or a form, but it can reside in objects such as Worksheets as well! Notice that the code just given
makes calls to two subroutines. The
CopySection
subroutine does something rather tricky. It adds
Search WWH ::




Custom Search