less than greater than for large amount of data

excelnoob123456

New Member
Joined
Mar 7, 2015
Messages
39
Hi Guys

I am OK with Excel and I know a way that I can do this, using If and AND formulae, but I feel there must be a neater way to do this given the large amount of data I'm working with would make my formula a bit unwieldy.

See example data below:

ABCEFGHIJ
1TypeSizeASizeB222 (sizeA)222 (sizeB)
555 (size a)

<tbody>
</tbody>
555 (size b)
2
222

<tbody>
</tbody>
1436

<tbody>
</tbody>
2725
2000

<tbody>
</tbody>
1500
1200

<tbody>
</tbody>
1500
3
234

<tbody>
</tbody>
1303

<tbody>
</tbody>
1984
2000

<tbody>
</tbody>
2100
1300

<tbody>
</tbody>
1700
4
607

<tbody>
</tbody>
1237

<tbody>
</tbody>
1953
2000

<tbody>
</tbody>
2550
1500

<tbody>
</tbody>
1900
5
555

<tbody>
</tbody>
1224

<tbody>
</tbody>
2075
2550

<tbody>
</tbody>
150015001200
6
2550

<tbody>
</tbody>
210016001300

<tbody>
</tbody>

Now, in my data all of the types (eg. 222,234,607,etc) have their own sizes as shown, but I want to return the 'allowable size' from the tables to the right, all of the types have their own different allowable sizes and sometimes the values they have can be outside of the allowable range, in which case I would like to display "width too large" for example. Now, in reality the SizeA and B are both in the same cell eg. 1224x2075 for both sets of data, and I think I will add columns where I seperate this out to make the formula easier. So currently my thinking would be to do something like:

Code:
=IF(and(A2=F1,b2<=f2,c2<=g2),concatenate(f2&"x"&g2),if(and(a2=f1,b2<=f2,c2>g2,c2<=g3),concatenate(f2&"x"&g3),etc.(

Going through the who line of options this would be quite a cumbersome formula, I think there must be an easier way to do this but I'm not sure how?

Any help greatly appreciated.
 
Last edited:

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Can you provide some more examples to illustrate, and also show the results you're expecting?

I'm guessing that if you had a 222 with dimensions 1800 x 1400, you'd return "2000x1500"?

What about a 222 with dimensions 1400 x 1400 where the allowable sizes include 1500x2000 and 1800x1600? Do you first choose the smallest A that will fit and return 1500x2000, or first choose the smallest B that will fit and return 1800X1600?

etc etc ...

For the 222 and 555 examples posted, both B sizes exceed the ranges available, so presumably you'll want to say "Size B too large"?
 
Upvote 0
Hi Stephen

Thanks for the reply. I will try to clarify what I'm trying to do a bit better...

I need to return the allowed values which are either bigger of the same size as the actual values, in the case where there is more than one acceptable size I would like the option with the smallest total area (sizea multiplied by sizeb). I only want the error displayed if there are no allowable sizes which will fit the actual size.

I should clarify as well that the Size A and Size B are linked, e.g. for a piece of wood, so if the actual size they want is a 1500x1234 (sizea x sizeb) I need to find the nearest size that would be bigger or as big as that overall. So for my example, I am comparing the sizes in b2 and c2, which is type 222 (cell a2) to the allowable sizes for a type 222 in f2:g6, so I would check first if b2 is less than or equal to f2 AND c2 is less than or equal to g2, say b2 is but c2 isn't, then I would check c2 against g3, g4 etc. and same with c2 if it didn't match.

I know that this will work but there are more tables than this so there are quite a large number of possible variations which would make the formula quite big, so if there was another option that would be excellent.

Hope this makes sense, it's hard to explain when writing.
 
Last edited:
Upvote 0
Perhaps something like this ...

I have used a helper column, so that the formula isn't twice as long.

Not checked in great detail yet, so see if you can break it!

D3 (array-entered): =MATCH(MIN(IF((INDEX(Sizes,,MATCH(A3,Headers,))>=B3)*(INDEX(Sizes,,1+MATCH(A3,Headers,))>=C3)+(INDEX(Sizes,,MATCH(A3,Headers,))>=C3)*(INDEX(Sizes,,1+MATCH(A3,Headers,))>=B3),INDEX(Sizes,,MATCH(A3,Headers,))*INDEX(Sizes,,1+MATCH(A3,Headers,)))),IF((INDEX(Sizes,,MATCH(A3,Headers,))>=B3)*(INDEX(Sizes,,1+MATCH(A3,Headers,))>=C3)+(INDEX(Sizes,,MATCH(A3,Headers,))>=C3)*(INDEX(Sizes,,1+MATCH(A3,Headers,))>=B3),INDEX(Sizes,,MATCH(A3,Headers,))*INDEX(Sizes,,1+MATCH(A3,Headers,))),)

E3: =INDEX(Sizes,D3,MATCH(A3,Headers,))&"x"&INDEX(Sizes,D3,1+MATCH(A3,Headers,))


Book1
ABCDEFGHIJKLMN
1222222234234555555607607
2TypeSizeASizeBMatchResult?SizeASizeBSizeASizeBSizeASizeBSizeASizeB
32221436205042550x150020001500120015001200150012001500
42341303170031500x190020002100130017001300170013001700
56071237145051600x130020002550150019001500190015001900
65551224150051600x130025501500150012001500120015001200
76071450123751600x130025502100160013001600130016001300
86071237145051600x1300
960712371950#N/ANo can do!
Sheet1
 
Last edited:
Upvote 0
Perhaps something like this ...

I have used a helper column, so that the formula isn't twice as long.

Not checked in great detail yet, so see if you can break it!

D3 (array-entered): =MATCH(MIN(IF((INDEX(Sizes,,MATCH(A3,Headers,))>=B3)*(INDEX(Sizes,,1+MATCH(A3,Headers,))>=C3)+(INDEX(Sizes,,MATCH(A3,Headers,))>=C3)*(INDEX(Sizes,,1+MATCH(A3,Headers,))>=B3),INDEX(Sizes,,MATCH(A3,Headers,))*INDEX(Sizes,,1+MATCH(A3,Headers,)))),IF((INDEX(Sizes,,MATCH(A3,Headers,))>=B3)*(INDEX(Sizes,,1+MATCH(A3,Headers,))>=C3)+(INDEX(Sizes,,MATCH(A3,Headers,))>=C3)*(INDEX(Sizes,,1+MATCH(A3,Headers,))>=B3),INDEX(Sizes,,MATCH(A3,Headers,))*INDEX(Sizes,,1+MATCH(A3,Headers,))),)

E3: =INDEX(Sizes,D3,MATCH(A3,Headers,))&"x"&INDEX(Sizes,D3,1+MATCH(A3,Headers,))

ABCDEFGHIJKLMN
1222222234234555555607607
2TypeSizeASizeBMatchResult?SizeASizeBSizeASizeBSizeASizeBSizeASizeB
32221436205042550x150020001500120015001200150012001500
42341303170031500x190020002100130017001300170013001700
56071237145051600x130020002550150019001500190015001900
65551224150051600x130025501500150012001500120015001200
76071450123751600x130025502100160013001600130016001300
86071237145051600x1300
960712371950#N/ANo can do!

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>

Thanks very much Stephen I'll try this tomorrow! This is the sort of thing I was thinking of, using arrays to make it shorter but I couldn't think how to do it. I'll let you know the results :)
 
Upvote 0
... where

Headers: G1:N1
Sizes: G3:N7

Can't quite work out how this is supposed to work, I tried it as you have typed it always n/a's out and I evaluated the formula and the numbers being multiplied means it eventually ends up with something like match(2500000,250000) which of course returns n/a, looking into how to get it to work at the minute but I don't quite get how it's supposed to work at the moment tbh.
 
Upvote 0
Last edited:
Upvote 0
Hi!

Maybe the suggestions below can help you (with StephenCrump's layout)

Lets go:

1) Created the names below in Sheet1:

HTable - Refers to: =Sheet1!$G$1:$N$1

DTable - Refers to: =Sheet1!$G$3:$N$7

2) Created the names below (with cell D3 selected) in Sheet1:

ColSA - Refers to: =MATCH(Sheet1!$A3,HTable,0)

RowRes - Refers to:

=MIN(IF(INDEX(IF(Sheet1!$A3=HTable,IF((Sheet1!$B3<=INDEX(DTable,,ColSA))*
(Sheet1!$C3<=INDEX(DTable,,ColSA+1)),DTable,0),0),,ColSA)>0,ROW(DTable)-ROW(INDEX(DTable,1,1))+1))


3) Finally, put the formula below in cell D2 and copy down:

=IFERROR(INDEX(DTable,RowRes,ColSA)&"x"&INDEX(DTable,RowRes,ColSA+1),"width too large")

Sheet1
ABCDEFGHIJKLMN
1222222234234555555607607
2TypeSizeASizeBResultSizeASizeBSizeASizeBSizeASizeBSizeASizeB
3222143620502000x210020001500120015001200150012001500
4234130317001500x190020002100130017001300170013001700
5607123714501300x170020002550150019001500190015001900
6555122415001300x170025501500150012001500120015001200
7607145012371500x190025502100160013001600130016001300
8607123714501300x1700
960712371950width too large
*****************************************************************************************

<tbody>
</tbody>


I hope that the suggestions above helps.

Markmzz
 
Upvote 0
Hi!

Another suggestion (more robust)

Lets go:

1) Created the names below in Sheet1:

HTable - Refers to: =Sheet1!$G$1:$N$1

DTable - Refers to: =Sheet1!$G$3:$N$7

Type - Refers to: =Sheet1!$A$3:$A$18

SizeA - Refers to: =Sheet1!$B$3:$B$18

SizeB - Refers to: =Sheet1!$C$3:$C$18

ColSA - Refers to: =MATCH(INDEX(Type,ROW()-ROW(INDEX(Type,1))+1),HTable,0)

DColSA - Refers to: =INDEX(DTable,,ColSA)

DColSB - Refers to: =INDEX(DTable,,ColSA+1)

ColAxColB - Refers to: =IF((INDEX(SizeA,ROW()-ROW(INDEX(SizeA,1))+1)<=DColSA)*(INDEX(SizeB,ROW()-ROW(INDEX(SizeB,1))+1)<=DColSB),DColSA*DColSB)

RowRes - Refers to: =MATCH(MIN(ColAxColB),ColAxColB,0)

2) Finally, put the formula below in cell D2 and copy down:

=IFERROR(INDEX(DColSA,RowRes)&"x"&INDEX(DColSB,RowRes),"width too large")

Sheet1
ABCDEFGHIJKLMN
1222222234234555555607607
2TypeSizeASizeBResultSizeASizeBSizeASizeBSizeASizeBSizeASizeB
3222143620502000x210020001500120015001200150012001500
4234130317001500x190020002100130017001300170013001700
5607123714501300x170020002550150019001500190015001900
6555122415001300x170025501500150012001500120015001200
7607145012371600x130025502100160013001600130016001300
8607123714501300x1700
960712371950width too large
1022214362735width too large
1123413031984width too large
1260712371953width too large
1355512242075width too large
14222255021002550x2100
15234160013001600x1300
16222200015002000x1500
17234120019001500x1900









18234150012001500x1200
*****************************************************************************************

<tbody>
</tbody>


I hope that the new suggestions above helps.

Markmzz
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,793
Messages
6,121,617
Members
449,039
Latest member
Mbone Mathonsi

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