One approach ..
Assume your table as posted is in Sheet1,
cols A and B, data from row2 down,
and in col B are *numbers* custom formatted as "0000"
partcode value
201 0100
302 0019
147 0001
201 0098
201 0102
147 0002
Enter a label in C1: ValueText
Put in C2: =TEXT(B2,"0000")
Copy C2 down
[This col C is created to illustrate the scenario
if the "numbers" in col B are *text*]
Let's create 3 dynamic ranges
for cols A to C in Sheet1:
Partcode :
=OFFSET(Sheet1!$A$1,,,SUMPRODUCT((Sheet1!$A$1:$A$65535<>"")
*1),1)
ValNum :
=OFFSET(Sheet1!$B$1,,,SUMPRODUCT((Sheet1!$B$1:$B$65535<>"")
*1),1)
ValText :
=OFFSET(Sheet1!$C$1,,,SUMPRODUCT((Sheet1!$C$1:$C$65535<>"")
*1),1)
To create the dynamic ranges,
click Insert > Name > Define
and in the dialog "Define Name":
Enter the Name in the "Names in workbook" box,
Paste the formula in the "Refers to" box
Click Add
(Repeat steps to add another name)
---------
In Sheet2
---------
Assume the partcodes will be entered in A2 down:
Put in A2: 201
Put in B2: =MAX(IF(Partcode=A2,ValNum))
[Array-enter]
Put in C2: =MAX(IF(Partcode=A2,ValText+0))
[Array-enter]
Array-entering the formulas in B2 and C2 means:
Press CTRL+SHIFT+ENTER, instead of just pressing ENTER
Done correctly, Excel will wrap curly braces { }
around the formula, viz. it will appear:
In B2:{=MAX(IF(partcode=A2,ValNum))}
In C2:{=MAX(IF(partcode=A2,ValText+0))}
Do not type-in the curly braces!
Custom format B2 and C2 as "0000"
Select B2:C2 and copy down
Cols B and C will return the max value for the partcodes
listed in col A from the table in Sheet1
The use of dynamic ranges will take care of the
table becoming longer day-by-day in Sheet1
--
Rgds
Max
xl 97
---
Please respond in thread
xdemechanik <at>yahoo<dot>com
----
dennis said:
i've got a excel table like this:
partcode value
201 0100
302 0019
147 0001
201 0098
201 0102
147 0002
i would like a cell that returns the max. no. in the "value" column
for a particular partcode. Say, if i want to know the max. value for
partcode "201", it will return "0102". How to do it if the table will
get longer and longer (ie. more partcode to enter) day after day ?
jack
.