Nested IF statements, or a better way?

wizau

New Member
Joined
Apr 1, 2014
Messages
6
Hello everyone,
Seeking some help for a project I'm working on. The scenario is approx 150x regional offices, that every year have an intake of 30-40 (sometimes up to 70) volunteers each office. These volunteers are entitled to a Uniform supplied by the organization. I am creating a spreadsheet that takes a volunteer's measurements (Head, Neck, Chest, Arm, Waist, Inseam, Foot - currently written down by hand on a form) and translates that into the available clothing sizes, and creates both the bulk order to the supplier, and each volunteer's 'Picking Card' when the clothing stock arrives. When the uniform stock arrives, we get a garbage bag with the volunteer's name and chuck all the uniform bits from the delivery boxes into the volunteer's named bag. This takes at least 2ppl 2x days as they sort through all the bits and use the paper Measurement Forms to translate in their head (or using the Size Matrixes) what size is needed to be put in the bag.

Yes, this system SUCKS!

Now that you have the background to understand the project, here is my request for assistance:

Attached for an example, are the sizing matrixes for the Long Sleeve Shirts & Trousers:
Shirts are Collar Size (Neck) and Sleeve Length (Arm) in cms. ie. 40/79. (The Short/Reg/Long 'fitments' are NOT labelled on the shirts or used to order, only the numbers.)
Trousers are labelled and ordered in Inches and the 'Fitment'. ie. 36Short, 38Long. (The cm measurements in the matrix are NOT accurate and are not labelled on the garment, or used.)
Shirts Matrix.jpg
Pants Matrix.jpg


Just to explain the process I'm following in my head:
The pants are actually sized and labelled in inches, but everything else is sized in cm, so we take measurements in cm, as Australia is a Metric country.
Take the cm waist measurement from the volunteer, convert it to inches and CEILING to every 2nd inch between 26 & 46.
('sanity checked' using Data Validation of whole number between 60cm & 120cm on the measurement data entry point)
For each waist size, take the inseam measurement and select the available corresponding 'Fitment': X-Short/Short/Reg/Long/X-Long.
TEXTJOIN the CEILING inches waist value to the Fitment value & output as 'Trouser Size'.
Pivot Table all the different trouser sizes for every volunteer, to COUNT how many of each size needs to be ordered from the Supplier, and EXPAND to lookup what size are for which volunteers, to make picking & packing easier. But every garbage bag will have a card on it that lists what should be put in this bag, as a double check.

This is the code I have so far for the trousers.
But I've stuffed up somewhere as I added the 36-46in section for the trousers.
The first 26in section worked, as did the 28-34 section when I added it.
But I broke it and can't work out how to fix it when I added the 36-46 section.
I stayed up till 5:20am trying to sort it, before I resorted to ask for help here.
Excel Formula:
=IF(O2=26, ((IF(I2<71,"X-Short","Short")))
,
((IF(O2<35,
  (IF(I2<71,"X-Short",
   (IF(I2<76,"Short",
    (IF(I2<86,"Reg",
     (IF(I2<91,"Long",
      (IF(I2>90,"X-Long"
))))))))))))
,
((IFO2>35,
 (IF(I2<76,"X-Short",
  (IF(I2<81,"Short",
   (IF(I2<90,"Reg",
    (IF(I2<100,"Long",
    (IF(I2>99,"X-Long"
))))))))))))
)

Hopefully if you're still reading, you will see I'm not asking for people to do my work for me, I just need some help checking all the nested IF statements, as I had it working up until the last addition.
Or tell me there's a much better way to do this, (VLOOKUP??) and I will go and learn how to do that.

This nested IF statement method has worked fine for T-Shirts, Hats, Socks, Jackets, anything that doesn't have multiple 'fitment' sizes for each size, and are just generic Small/Med/Large/X-Large/XXL/XXXL.

Thanks for any assistance, as there's currently 144x Supply officers (who are also all volunteers on top of their day jobs!) that will thank you for making their lives so much easier every year at recruiting time.

Thank you.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Try this as replacement of nested IF formula.
Excel Formula:
=IF(O2=26, IF(I2<71,"X-Short","Short"),IF(O2<35,INDEX({"X-Short","Short","Reg","Long","X-Long"},MATCH(I2,{0,71,76,86,91,1000},1)),INDEX({"X-Short","Short","Reg","Long","X-Long"},MATCH(I2,{0,76,81,90,100,1000},1))))
 
Upvote 0
Solution
Using the shirts table as an example, you can use a combination of INDEX and MATCH formulas.

Assumptions made:
  • Your table with shirt data can be found on Sheet1 cells A1 to P11.
  • The entry form for the neck size is on Sheet2 cell A1.
  • The entry form for the arm length is on Sheet2 cell A2.

When you use an INDEX formula, you have to enter three criteria. The data range you are looking in, the row number your desired data is in and the column number your desired data is in.

You know the data range you are looking for. It's shirts tables on Sheet1!A1:P11.
Let's start with what we know: =INDEX(Sheet1!$A$1:$P$11,ROWNUMBER,COLUMNNUMBER).

So you're missing the desired row number and column number.
The formula will need the row number first, but I will explain the column number first. It has no missing column headers making the explanation easier (the arm length skips sizes 71, 73, 75...).

To get the column number you can use a MATCH formula.
Select the range of cells in which you want to find a value.
In this case you want to know where in Sheeet1!A1:P1 the neck size entered in cell Sheet2!A1 can be found.
That's done using: =MATCH(Sheet1!$A$1,Sheet2!$A$1:$P$1,0)
This formula returns the column number, so for size 31 the answer would be 3 (cell Sheet1!C1), for size 32 the anwer would be 4 (cell Sheet1!D1).

Add that to the INDEX formula created earlier:
=INDEX(Sheet1!$A$1:$P$11,ROWNUMBER,MATCH(Sheet1!$A$1,Sheet2!$A$1:$P$1,0)).

For the row number (arm length), you are missing values so a straight match like for the neck sizes won't work. You need the closest match greater then entered.
For that you can use this formula: =MATCH(TRUE,INDEX(Sheet1!$A$3:$A$11>=Sheet2!$A$2,0),)+2
It uses a MATCH formule to find the closest match, then an INDEX formula to return the row number of the closest match.
Note that this should only look at the numbers! That's why the INDEX formula does not look at Sheet1!$A$1:$A$11, but at Sheet1!$A$3:$A$11.
To make up for that at the end of the formula a +2 has been added.

Add that to the INDEX formula created earlier:
=INDEX(Sheet1!$A$1:$P$11,MATCH(TRUE,INDEX(Sheet1!$A$3:$A$11>=Sheet2!$A$2,0),)+2,MATCH(Sheet2!$A$1,Sheet1!$A$1:$P$1,0))
 
Upvote 0
Yes, Thank you. I'm already modifying the provided information for the 'WORK Shirts" which only have Chest measurement of 5cm increments & Short/Reg/Long fitments.
I'll follow your example and put the Long Sleeve Shirt data in their own table, rather than programming into the formula. I know this is better practice in case we change shirt suppliers and need to alter the sizes, we only need to edit the table, not every formula.
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,790
Members
451,589
Latest member
Harold14

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