Microsoft Office Tutorials and References
In Depth Information
What Makes a Good Utility?
End If
End If
End If
On Error Resume Next
Set Rng = Intersect(Rng, Rng.Parent.UsedRange)
If TextOnly = True Then
Set CreateWorkRange = Rng.SpecialCells(xlConstants, xlTextValues)
If Err <> 0 Then
Set CreateWorkRange = Nothing
On Error GoTo 0
Exit Function
End If
Else
Set CreateWorkRange = Rng.SpecialCells _
(xlConstants, xlTextValues + xlNumbers)
If Err <> 0 Then
Set CreateWorkRange = Nothing
On Error GoTo 0
Exit Function
End If
End If
End Function
The CreateWorkRange function makes heavy use of the SpecialCells property. To
learn more about the SpecialCells property, try recording a macro while making
various selections in Excel’s Go To Special dialog box. You can display this dialog box
by pressing F5 and then clicking the Special button in the Go To dialog box.
It’s important to understand how the Go To Special dialog box works. Normally, it operates on
the current range selection. For example, if an entire column is selected, the result is a subset of
that column. But if a single cell is selected, it operates on the entire worksheet. Because of this,
the CreateWorkRange function checks the number of cells in the range passed to it.
Saving the Text Tools utility settings
The Text Tools utility has a very useful feature: It remembers the last settings that you used. This
feature is handy because many people tend to use the same option each time they invoke it.
The most recently used settings are stored in the Windows Registry. When the user clicks the
Close button, the code uses VBA’s SaveSetting function to save the value of each control.
When the Text Tools utility is started, it uses the GetSetting function to retrieve those values
and set the controls accordingly.
In the Windows Registry, the settings are stored at the following location:
HKEY_CURRENT_USER\Software\VB and VBA Program Settings\
Text Tools Utility\Settings
 
Search JabSto ::




Custom Search