ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Contains function help (https://www.excelbanter.com/excel-programming/326735-contains-function-help.html)

TonyL

Contains function help
 
I am trying to write a function where if the cell contains a certain string
to return the data upto that string else return the entire string. Here is
what I have so far:

=IF(SEARCH("(oc:",B1,1)0,LEFT(B1,SEARCH("(oc",B1, 1)-2),B1)

This works if the string exists in the cell but if it doesn't, it returns
#VALUE. Where am I going wrong? TIA
--
Tony

OJ[_2_]

Contains function help
 
Try this...

=IF(ISERROR(SEARCH("(oc:",B1,1)),B1,LEFT*(B1,SEARC H("(oc",B1,1)-2))

HTH,
OJ


TonyL

Contains function help
 
Thanks OJ. That did the trick

Tony

"OJ" wrote:

Try this...

=IF(ISERROR(SEARCH("(oc:",B1,1)),B1,LEFTÂ*(B1,SEAR CH("(oc",B1,1)-2))

HTH,
OJ




All times are GMT +1. The time now is 09:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com