Why wont the OR Function Work in this Formula?

bearwires

Board Regular
Joined
Mar 25, 2008
Messages
57
Office Version
  1. 365
Platform
  1. Windows
I've tried to make this formula more concise using the OR function, but it doesnt need to like it.
Have I done something wrong?
Any ideas how to make it work?

Before OR Function (Works):

Excel Formula:
=IF(ISNUMBER(SEARCH("M&E",D$41)),"Electrical & Mechanical",IF(ISNUMBER(SEARCH("Electrical",D$41)),"Electrical",IF(ISNUMBER(SEARCH("Fire Alarm",D$41)),"Electrical",IF(ISNUMBER(SEARCH("Mechanical",D$41)),"Mechanical",IF(ISNUMBER(SEARCH("Plumbing",D$41)),"Mechanical",IF(ISNUMBER(SEARCH("AC",D$41)),"Mechanical",IF(ISNUMBER(SEARCH("Ventilation",D$41)),"Mechanical",IF(ISNUMBER(SEARCH("Ductwork",D$41)),"Mechanical",IF(ISNUMBER(SEARCH("Temps",D$41)),"Electrical & Mechanical",IF(ISNUMBER(SEARCH("Pull Testing",D$41)),"Electrical & Mechanical",IF(ISNUMBER(SEARCH("Pipework",D$41)),"Mechanical",IF(ISNUMBER(SEARCH("Pump",D$41)),"Mechanical",IF(ISNUMBER(SEARCH("AHU",D$41)),"Mechanical",IF(ISNUMBER(SEARCH("Chiller",D$41)),"Mechanical",IF(ISNUMBER(SEARCH("BMS",D$41)),"Mechanical",IF(ISNUMBER(SEARCH("SPARE",D$41)),"TBC-GIVE MS A NAME","NAME RA CORRECTLY"))))))))))))))))

With OR Function (Don't Work):

Excel Formula:
=IF(ISNUMBER(SEARCH(OR("M&E","Temps","Pull Testing"),D$41)),"Electrical & Mechanical",IF(ISNUMBER(SEARCH(OR("Electrical","Fire Alarm"),D$41)),"Electrical",IF(ISNUMBER(SEARCH(OR("Mechanical","Plumbing","AC","Ventilation","Ductwork","Pump","AHU","Chiller","BMS"),D$41)),IF(ISNUMBER(SEARCH("SPARE",D$41)),"TBC-GIVE MS A NAME","NAME RA CORRECTLY"))))
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Are the phrases like M&E, Temps etc the only contents of the cell, or are they part of larger strings?
 
Upvote 0
You can use this syntax::

=IF(COUNT(SEARCH({"M&E","Temps","Pull Testing"},D$41)),"Electrical & Mechanical",

...etc
 
Upvote 0
Are the phrases like M&E, Temps etc the only contents of the cell, or are they part of larger strings?
The cell rely on manual input so I would like the formula to accommodate larger text strings including those words if possible. For example, if I typed “Temps - Lighting”, I’d like the formula to result in “Electrical” or if I typed “Temps - AC”, it should be “Mechanical” result.
 
Upvote 0
Ok, you can either do it as Rory has shown, or another option is like
Excel Formula:
=IF(SUM(COUNTIFS(D$41,{*"M&E*","*Temps*","*Pull Testing*"})),"Electrical & Mechanical",IF(SUM(COUNTIFS(D$41,{"*Electrical*","*Fire Alarm*"})),"Electrical"
 
Upvote 0
Solution
Ok, you can either do it as Rory has shown, or another option is like
Excel Formula:
=IF(SUM(COUNTIFS(D$41,{*"M&E*","*Temps*","*Pull Testing*"})),"Electrical & Mechanical",IF(SUM(COUNTIFS(D$41,{"*Electrical*","*Fire Alarm*"})),"Electrical"
Thanks Fluff, it works great.
Rory's solution also works but I cant mark both as a solution.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,390
Members
448,957
Latest member
Hat4Life

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