Difference between revisions of "Documentation/How Tos/Calc: SEARCH function"
From Apache OpenOffice Wiki
< Documentation | How Tos
(Added example to cover case where substring is not present.) |
m |
||
(4 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | __NOTOC__ | + | {{DISPLAYTITLE:SEARCH function}} |
+ | {{Documentation/CalcFunc TextTOC | ||
+ | |ShowPrevNext=block | ||
+ | |PrevPage=Documentation/How_Tos/Calc:_ROMAN_function | ||
+ | |NextPage=Documentation/How_Tos/Calc:_SUBSTITUTE_function | ||
+ | }}__NOTOC__ | ||
== SEARCH == | == SEARCH == | ||
Line 16: | Line 21: | ||
: A failed search gives the <tt>'''#VALUE!'''</tt> error. | : A failed search gives the <tt>'''#VALUE!'''</tt> error. | ||
− | : In | + | : In {{menu|Tools|Options|OpenOffice Calc|Calculate}} the setting for <i>Search criteria = and <>must apply to whole cells</i> has no effect. |
=== Example: === | === Example: === | ||
Line 37: | Line 42: | ||
:: <tt>'''IF( ISNUMBER( SEARCH("xyz","abcdef",1) ) , "Substring Present", "ERR: Missing Substring" )'''</tt>. | :: <tt>'''IF( ISNUMBER( SEARCH("xyz","abcdef",1) ) , "Substring Present", "ERR: Missing Substring" )'''</tt>. | ||
::: returns <tt>'''"ERR: Missing Substring"'''</tt> (... allowing the IF() to function, and not propagating the error from the SEARCH() function. | ::: returns <tt>'''"ERR: Missing Substring"'''</tt> (... allowing the IF() to function, and not propagating the error from the SEARCH() function. | ||
− | :: NOTE: In practice, it may be more maintainable to use ISNUMBER() to avoid negative logic, and it is more | + | :: NOTE: In practice, it may be more maintainable to use ISNUMBER() to avoid negative logic, and it is more indicative of the evaluation desired: if the substring has a position, then ISNUMBER() is TRUE, else ISNUMBER() is FALSE. |
− | {{ | + | |
+ | |||
+ | {{SeeAlso|EN| | ||
* [[Documentation/How_Tos/Calc: REPLACE function|REPLACE]] | * [[Documentation/How_Tos/Calc: REPLACE function|REPLACE]] | ||
* [[Documentation/How_Tos/Calc: FIND function|FIND]] | * [[Documentation/How_Tos/Calc: FIND function|FIND]] |