Error in IFERROR formula

ijhoeq

Board Regular
Joined
Jun 20, 2018
Messages
61
Hello,

I have the code shown below which runs properly and fills in columns with a "0" if the search work (in cell I1) is not present in cell B2. I would like for the cells to display " - " instead of "0" but I get "Run-time error '13' Type Mismatch". Can anyone explain why or how to accomplish this please?
Code:
LastRow = Worksheets("Filtered Data").Range("B" & Rows.Count).End(xlUp).Row

'THIS CODE BELOW POPULATES WITH "0" AND WORKS FINE
Worksheets("Filtered Data").Range("I2:I" & LastRow).Formula = "=IFERROR(IF(SEARCH(I$2,$B2)>0,I$1,),)"

'THIS CODE BELOW DOES NOT WORK AND RESULTS IN RUN-TIME ERROR
Worksheets("Filtered Data").Range("I2:I" & LastRow).Formula = "=IFERROR(IF(SEARCH(I$1,$B2)>0,I$1,)," - ")"
Thanks!
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
DOuble quotes need to be escaped:
Code:
Worksheets("Filtered Data").Range("I2:I" & LastRow).Formula = "=IFERROR(IF(SEARCH(I$1,$B2)>0,I$1,),"" - "")"
 
Upvote 0
Maybe
Code:
"=IF(ISNUMBER(SEARCH(I$2,$B2)),I$1,""-"")"
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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