IF and MID and ELSE

smcelv

Board Regular
Joined
Jul 26, 2011
Messages
58
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

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
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,214,826
Messages
6,121,793
Members
449,048
Latest member
greyangel23

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