Microsoft Office Tutorials and References
In Depth Information
Example 19-6. The cmdUndo_Click Event Procedure
The Undo button returns the selection to its original state, which is saved in the module-level
variable rngForUndo . Its source code is shown in Example 19-6 .
Example 19-6. The cmdUndo_Click Event Procedure
Private Sub cmdUndo_Click()
If Not rngForUndo Is Nothing Then
rngForUndo.Select
cmdUndo.Enabled = False
End If
End Sub
The first thing the user will do after the dialog is displayed is choose an option from the frame at
the top. This choice will determine in part the search range. Also, some choices require a more
restrictive search range. To react to the user's choice, we call a procedure called
GetSearchRange whenever an option button is selected. The code to handle the option buttons
is shown in Example 19-7 .
Example 19-7. Event Handlers for the Option Buttons
Private Sub optDifferent_Click()
GetSearchRange
End Sub
Private Sub optEmpty_Click()
GetSearchRange
End Sub
Private Sub optNotEmpty_Click()
GetSearchRange
End Sub
Private Sub optSame_Click()
GetSearchRange
End Sub
The GetSearchRange procedure is shown in Example 19-8 .
Example 19-8. The GetSearchRange Procedure
Private Sub GetSearchRange()
' Set search range based on choice of search type.
' If Different or Same, validate range
' If single cell, change to:
' - used column for Different or Same match
' - used range for Empty or Not Empty match
' We know that rngSearch is a range of cells.
' Disables Select button if not a valid range.
Dim cColumns As Integer, cRows As Integer
cmdSelect.Enabled = True ' May be temporary
If optDifferent Or optSame Then
' Search range must be (portion of)
' a single row or column
cColumns = rngSearch.Columns.Count
 
 
 
 
Search JabSto ::




Custom Search