Is it possible to use SEARCH and OR functions together in excel when searching the "filename"

xcelnovice101

Active Member
Joined
Aug 24, 2012
Messages
368
I am trying to have a cell prepopulate based on the tab name which should be one of the following options:

"DB", "HC", "DB-HC", "HC-DB", "HC&DB" or "DB&HC"

Below is my formula in excel, not VBA and everything appears to be working except for the first section highlighted in red. I think it all comes down to using "&&" in the formula. I've tried "&" and that doesn't work either.

Code:
=IFERROR([COLOR=#ff0000]IF(SEARCH(OR("-","&&"),LEFT(MID(CELL("filename",M1),FIND("]",CELL("filename",M1))+1,255),5),1)>0[/COLOR],LEFT(MID(CELL("filename",M1),FIND("]",CELL("filename",M1))+1,255),5),LEFT(MID(CELL("filename",M1),FIND("]",CELL("filename",M1))+1,255),2)),LEFT(MID(CELL("filename",M1),FIND("]",CELL("filename",M1))+1,255),2))
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
I just tried the same formula but replaced "&&" with "+" and get the same results. When I go into the excel forumla bar on that section of the formula, excel provides the reults #VALUE! so I'm now thinking we can't do the OR Function in conjunction with the SEARCH function. Does anybody know is this is in fact the case?
 
Upvote 0

Forum statistics

Threads
1,207,094
Messages
6,076,550
Members
446,212
Latest member
KJAYPAL200

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