How to debug 'Wrong data type' problem (`SEARCH` function) ?

I’m using LO Calc 6.0.4.2 x64 on Window$ 7 Enterprise SP1 x64.

Even when I create a new spreadsheet and regardless of whether the cell referenced by SEARCH is formatted to be text or a number, I always get the Wrong data type error.

In Untitled 2.ods L2 uses a RegEx version, L3 a wildcard version and L4 a normal version.

Hi

SEARCH returns #VALUE! when the text is not found.

To avoid this, use the IFERROR function

=IF(IFERROR(SEARCH(".*destroyer.*";$A2);0)>0;1;  IF(IFERROR(SEARCH(".*cruiser.*"  ;$A2);0)>0;5;  IF(IFERROR(SEARCH(".*battle.*"   ;$A2);0)>0;15;  IF(IFERROR(SEARCH(".*mother.*"   ;$A2);0)>0;40))))

HTH - Regards

But if it didn’t find the text, why give Wrong data type ?

@rautamiekka

AFAIK No result = #VALUE (in the cell rather than Err:519!)

See help

Just for information, the function returns the same thing with Excel. Returning zero could make the function ambiguous (could be interpreted as a position)?

Regards