Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find method in Excel 97

Status
Not open for further replies.

wsuh

Programmer
Jun 28, 2001
6
US
I'm convinced that the find method in Excel 97 has problems. I cannot run the same code that runs on Excel 2000. I've tried using different installations of Excel 97 on differenct machines and no luck. I've copied code verbatim from books and the internet and still I get the same error message. run-time error '1004 unable to get find property of the range class.

Can someone shed some light on the find method? Thanks.

Dim rng1 As Range
Dim strCtrlNum As String

strCtrlNum = Application.InputBox("Enter Search String", "Find")

If strCtrlNum = "" Or IsNull(strCtrlNum) Then
Exit Sub
Else

Set rng1 = Cells.Find(What:=strCtrlNum).Activate

If rng1 Is Nothing Then
MsgBox "Can't find" & " " & strCtrlNum
Exit Sub
Else
rng1.Activate
End If

End If
 
This works...

Private Sub test()

Dim rng1 As Range
Dim c
Dim strCtrlNum As String

strCtrlNum = Application.InputBox("Enter Search String", "Find")

If strCtrlNum = "" Or IsNull(strCtrlNum) Then
Exit Sub
Else
With Worksheets(1).Range("a1:a500")

Set c = .Find(strCtrlNum, LookIn:=xlValues)

If c Is Nothing Then
MsgBox "Can't find" & " " & strCtrlNum
Exit Sub
Else
c.Activate
End If
End With
End If
End Sub
 
Database guy,

What version of Excel 97 are you using? I don't think SR-1, the version I'm using supports this method.
 
database guy,

your code doesn't work for me. Other users with Excel 97-SR2 have confirmed that my code works. Is it possible that Excel 97 Sr1 doesn't support the find method?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top