Multiple if and statement

DavosCH32

New Member
Joined
Jun 27, 2014
Messages
11
I have tried without success to use multiple if and statements for the below, but nothing is working. I can get 1 if statement for 1 group (Days) but not sure how to add the rest. I need the cell to return the Code based on the Days (Full Time, 90 Days, 30 Days) and Number (1+, 2+ etc).
Index match would not work here as the number could contain decimals.
For the example below if they select Full Time and the number value is 7.5, it should return the code "Code 3". Any help would be greatly appreciated.

1673386984874.png
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Based on your screenshot assuming Days data starts from cell E2, Numbers data starts from F2, this formula goes on G2 and drag down:
Excel Formula:
=IF(E2="30 Days",IF(F2>=1,"Code 5",""),IF(E2="90 Days",IF(F2>=2.5,"Code 5",IF(F2>=2,"Code 4",IF(F2>=1,"Code 2",""))),IF(E2="Full Time",IF(F2>=10,"Code 10",IF(F2>=8,"Code 4",IF(F2>=7,"Code 3",IF(F2>=6,"Code 2",IF(F2>=4,"Code 1",""))))),"")))
 
Upvote 0
how about
=INDEX($C$2:$C$10,MATCH(E2&F2,$A$2:$A$10&$B$2:$B$10,1))

or must it b a IF()

Book19
ABCDEFG
1
230 days1code 5full time7.5code 3
390 days1code 290 days1.5code 2
490 days2code 4
590 days2.5code5
6full time4code 1
7full time6code 2
8full time7code 3
9full time8code 4
10full time10code 5
11
Sheet1
Cell Formulas
RangeFormula
G2:G3G2=INDEX($C$2:$C$10,MATCH(E2&F2,$A$2:$A$10&$B$2:$B$10,1))
 
Upvote 0
Based on your screenshot assuming Days data starts from cell E2, Numbers data starts from F2, this formula goes on G2 and drag down:
Excel Formula:
=IF(E2="30 Days",IF(F2>=1,"Code 5",""),IF(E2="90 Days",IF(F2>=2.5,"Code 5",IF(F2>=2,"Code 4",IF(F2>=1,"Code 2",""))),IF(E2="Full Time",IF(F2>=10,"Code 10",IF(F2>=8,"Code 4",IF(F2>=7,"Code 3",IF(F2>=6,"Code 2",IF(F2>=4,"Code 1",""))))),"")))

Thank you iggydarsa!!!! This worked perfectly.
 
Upvote 0
how about
=INDEX($C$2:$C$10,MATCH(E2&F2,$A$2:$A$10&$B$2:$B$10,1))

or must it b a IF()

Book19
ABCDEFG
1
230 days1code 5full time7.5code 3
390 days1code 290 days1.5code 2
490 days2code 4
590 days2.5code5
6full time4code 1
7full time6code 2
8full time7code 3
9full time8code 4
10full time10code 5
11
Sheet1
Cell Formulas
RangeFormula
G2:G3G2=INDEX($C$2:$C$10,MATCH(E2&F2,$A$2:$A$10&$B$2:$B$10,1))
One of the easiest and quick resolution which i have seen... Kudos to you @etaf
 
Upvote 0
One of the easiest and quick resolution which i have seen... Kudos to you @etaf
Hmm, I think that depends on a couple of things.

a) If the data is really as posted in post 1 where the numbers are followed by a "+" sign. If that is the case then the formula does not necessarily return the correct result. The OP stated that this result should be "code 3"

23 01 12.xlsm
ABCDEFG
1
230 days1+code 5full time7.5code 2
390 days1+code 2
490 days2+code 4
590 days2.5+code 5
6full time4+code 1
7full time6+code 2
8full time7+code 3
9full time8+code 4
10full time10+code 5
Sample
Cell Formulas
RangeFormula
G2G2=INDEX($C$2:$C$10,MATCH(E2&F2,$A$2:$A$10&$B$2:$B$10,1))


b) If the "+" signs are not there, problems could still occur because of the different lengths of the numbers. For example, I believe this result should be "code 4"

23 01 12.xlsm
ABCDEFG
1
230 days1code 5full time8.5code 5
390 days1code 2
490 days2code 4
590 days2.5code 5
6full time4code 1
7full time6code 2
8full time7code 3
9full time8code 4
10full time10code 5
Sample
Cell Formulas
RangeFormula
G2G2=INDEX($C$2:$C$10,MATCH(E2&F2,$A$2:$A$10&$B$2:$B$10,1))


The problem is that for MATCH to use "1" as its final argument the values have to be arranged in alphabetical order and in that case "full time10" does not come after "full time8". (In fact it would come before all the other full time entries in the sample data)
 
Last edited:
Upvote 0
thanks for the error correction - Peter_SSs , i never knew that , i see now as adding the number makes it text and so the sort order changes - will keep that in mind for the future - Thanks again for taking the time to provide the correction
 
Upvote 0
Thanks again for taking the time to provide the correction
No problem - though I didn't actually provide a correction, just pointed out the potential problems. 😎

Given that the OP has stated that post #2 works perfectly, perhaps my comments about the "+" following the numbers may have been misguided in that the "+" may just be from some custom formatting rather than added text.

@DavosCH32
You might clarify the issue of the "+" signs just so we know.
But also, I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

For example, IF you have a version with the latest functions, and assuming column B is numerical, you could use this which again is much shorter than the post 2 suggestion. :)

23 01 12.xlsm
ABCDEFG
1
230 days1Code 5full time7.5Code 3
390 days1Code 290 days1.5Code 2
490 days2Code 4
590 days2.5Code 5
6full time4Code 1
7full time6Code 8
8full time7Code 3
9full time8Code 4
10full time10Code 5
Code
Cell Formulas
RangeFormula
G2:G3G2=INDEX(SORT(FILTER(B$2:C$10,(A$2:A$10=E2)*(B$2:B$10<=F2)),1,-1),1,2)
 
Upvote 0

Forum statistics

Threads
1,223,639
Messages
6,173,499
Members
452,516
Latest member
druck21

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