"Find Property of the Range Class"

yippie_ky_yay

Board Regular
Joined
Jun 25, 2002
Messages
63
Hello Forum,

I have been trying to implement a search across all worksheets using examples found in this forum.

I have tried a couple, but always get:
"Run-Time Error 1004: Unable to get the Find Property of the Range Class". And, as suspected, in the debugger the line with ".Find" in it is what is highlighted.

I am using '97 - any thoughts on what I may be doing wrong.

Any help would be greatly appreciated!

-Sean
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hey Andrew - thanks for replying.

One example is:
Dim ws As Worksheet
For Each ws In Worksheets
ws.Select
Cells.Find(What:=txtContractSearch).Activate
Next

On line 4 ("Cells.Find....") is where the debugger stops.

Another example from the same post:

Dim Message, Title, Default, SearchString
Message = "Enter your search string!" ' Set prompt.
Title = "Find ? On all sheets!" ' Set title.
Default = "" ' Set default.
' Display message, title, and default value.
SearchString = InputBox(Message, Title, Default)
Set S = Sheets.Application
For Each S In Application.Sheets
With S.Range("A1:IV65536")
Set F = .Find(SearchString, MatchCase:=True, LookAt:=xlWhole, LookIn:=xlValues)
If F Is Nothing Then
MsgBox "Not Found!"
Else
Location = F.Address
S.Select
Range(Location).Select
Exit For
End If
End With
Next S

Doesn't like the Set F = .Find....


Thanks!
This message was edited by yippie_ky_yay on 2002-09-17 09:47
 
Upvote 0
Your code will fail on Activate if no match is found. This worked for me.

Code:
Sub Test()
    Dim txtContractSearch As String
    Dim c As Range
    txtContractSearch = "Test"
    Set c = ActiveSheet.Cells.Find(What:=txtContractSearch)
    If Not c Is Nothing Then c.Activate
End Sub

Maybe you need:

ws.Cells.Find(What:=txtContractSearch)

I don't know about the second example. It should work if F is declared as Range.
 
Upvote 0
Hey Andrew,

I used your exact code and still get:
"Run-Time Error 1004: Unable to get the Find Property of the Range Class".

It must be something on my machine then huh?
 
Upvote 0
Strange. This is an extract from Help - it may be relevant.

Remarks

The settings for LookIn, LookAt, SearchOrder, and MatchByte are saved each time you use this method. If you don’t specify values for these arguments the next time you call the method, the saved values are used. Setting these arguments changes the settings in the Find dialog box, and changing the settings in the Find dialog box changes the saved values that are used if you omit the arguments. To avoid problems, set these arguments explicitly each time you use this method.
 
Upvote 0
Hey Andrew,

thanks for all your help on this - I figured it out. All I had to do was set the "TakeFocusOnClick" to false on my command button and the rest of your code worked perfectly!

Thanks again,

-Sean
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,585
Members
448,972
Latest member
Shantanu2024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top