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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
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,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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