View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Frank Drost
 
Posts: n/a
Default very long statement

I have to create a very long formula for my cells. I hope someone can help me
with this.

I have a table, y nr of rows, x nr of columns. The numbers in the first row
of the table represents groups. In the example below, nr 1 and 2 are part of
a group, 4,5 and 6 of a second group, and 8 and 9 are part of group 3. For
each row, I have to find which group's sum is the maximum, find the maximum
value in that group, and then return the first row's corresponding position's
value. Below is an example.

A B C D E F G
1 | 1 2 4 5 6 8 9
2 | 6 7 3 4 3 1 8
3 | 2 2 1 3 9 5 1
4 | 8 4 0 9 4 1 0


So for row 2, find the maximum sum of each group: MAX(SUM(A2:B2)),
SUM(C2:E2), SUM(F2:G2)). This is the max of (13,10,9). So group one has the
largest sum (=13). Somehow the statement has to realise then that it has to
look for the maximum value in group 1, MAX(group 1). That value is then 7,
which is in the second cell of the row. Since the second cell of the row is
the location I am after, the output needs to be then the second cell of row
1, which is value nr 2.
For the third row, the story goes: Find maximum(2+2,1+3+9,5+1). The maximum
is group 2 (=13). Then find maximum in group 2, which is 9, which is cell nr
5 in that row. The equivalent position on the first row has value 6 and that
is the answer.
for row 4, max(12,13,1). Max is group 2. Max in group 2 is 9. Location is
cell 4 in tha row. Value of cell 4 in first row is 5 which is the answer.

As you can see, it needs a lot of statements. Does anyone know of a tidy way
of doing this?

ta