Type mismatch using Find method

BoBeau

New Member
Joined
May 5, 2011
Messages
3
Hi
I'm using Excel2003. I have a number of cells in a sheet with a formula similar to "=IF((RC[-57]+RC[-38])>20;IF(RC[-19]>=0,07;"XX";"");"")"

I need my VBA code to find these cells and perform some action. If I use code like

Set b = Cells.Find("XX")

I can find the cells that have the VALUE "XX", but I need to find all the cells with the formula. My problem is that if I use instead

Set b = Cells.Find("XX", xlFormulas)

I get a "Runtime error 13 - Type Mismatch".
Any advice or ideas are much appreciated.
Thx
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Welcome to the forums!

Try:

Set b = Cells.Find("XX", LookIn:=xlFormulas)

The second argument to the Find method is "after", so without explicitly declaring LookIn:=, the method is trying to say "After:=xlFormulas", which is msimatched.
 
Upvote 0
Just tried the "Lookin" suggestion and that did the trick. :) Thought the "xlFormulas" was reserved enough to be understood, but apparantly not.
Well spotted and thanks a lot for your help.
Regards
 
Upvote 0
Just tried the "Lookin" suggestion and that did the trick. :) Thought the "xlFormulas" was reserved enough to be understood, but apparantly not.
Well spotted and thanks a lot for your help.
Regards

Anything in VBA that is "xl*something*" or "vb*something*", like "xlFormulas", "xlUp", "xlToLeft", etc, are all constants that are set so we don't have to remember things like -4123 for xlFormulas, -4162 for xlUp, or -4159 for xlToLeft. :biggrin:
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,626
Members
452,933
Latest member
patv

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