IF and MID and ELSE

smcelv

Board Regular
Joined
Jul 26, 2011
Messages
59
Could someone please help me to add multiple functions in a search string?

=IF(MID(B18,2,8)="01330701","11-13 hours","") is giving me the desired result for that one formula.

I need to check B18 for 5 different number sequences which would return the same, "11-13 hours" result if met.
For example =IF(MID(B18,2,8)="01732401","11-13 hours","") Would give me the desired "11-13 hours" too.

Thank you in advance for any help you can supply.

Sam
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Try this for two of them, and if you get this working, you can adapt it for five

Code:
=if(or(MID(B18,2,8)="01330701",MID(B18,2,8)="01732401"),"11-13 hours","")

A better approach might be something like
Code:
=if(isna(vlookup(mid(b18,2,8),c1:c5,1,false)),"","11-13 hours")
where c1:c5 contains the 5 codes you want to compare against.
 
Upvote 0
You can use OR
Code:
=IF(OR(MID(B18,2,8)="01330701",MID(B18,2,8)="01732401",next sequences goes here,.. ),"11-13 hours","")
 
Upvote 0
Another option, lets say you have placed the codes in to cells a1:a5

Then:
=IF(COUNTIF(a1:a5,MID(b1,2,8))=1,"11-13 hours","")

Where b1 is the first cell to check
 
Upvote 0
Thank you Gerald

Much appreciated.

Done what you suggested and just added to your formula.
Working fine now.

Again, many thanks.
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,144
Members
453,021
Latest member
Justyna P

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