User Form Error Excel 2003!
Hello,
I'm tring to create a User Form to select a range and find data within
cells in the selected range. But I'm getting this error message
Run-time error '13'
Type mismatch
then it highlights this part of the code:
SelRange(oSearch.Address).Activate ' or whatever
How can the code be changed work without errors?
The complete code:
Private Sub CommandButton1_Click()
Dim SelRange As Range
Dim Addr As String
Dim oSearch As Object
Dim sFind As String
'Get the address, or reference, from the RefEdit control.
Addr = RefEdit1.Value
'Set the SelRange Range object to the range specified in the
'RefEdit control.
Set SelRange = Range(Addr)
'Apply a red pattern to the SelRange.
'SelRange.Interior.ColorIndex = 3
'Finds the information
sFind = TextBox1.Value 'InputBox("Enter search criteria:", "Data")
With SelRange 'ActiveSheet.Range("D2:D24000")
Set oSearch = .Find(sFind, , xlValues)
If Not oSearch Is Nothing Then
SelRange(oSearch.Address).Activate ' or whatever
Else
MsgBox "No match could be found"
End If
End With
'Unload the userform.
Unload Me
End Sub
Thanks in advsnce for your help,
James Cooper
|