Index Match Return Column # based on Sum of Columns

mkrecknagel

New Member
Joined
Apr 3, 2019
Messages
2
Hello All!

Long time reader of this site, but currently I cannot find a solution to my problem.

For a little background info this table is a planned amount of events at each location per month. And the formula is reading this table and transferring the information into a new list on another worksheet, thus this table cannot be sorted and the output list (formula) should return the outputs from left to right. An Array formula would be acceptable, but I do not want to use VBA as I am not well versed in them and I like the instant and live results of formulas. Also because this workbook will be sent out to Excel users who have very little knowledge and must be automatic, efficient and work seamlessly in the background with no other involvement than predefined inputs.

Named Range (A15:G20) = Events, Located on Sheet1
ABCDEFG
15RedmondBeijingDublinHyderabadMunichSingapore
16Jul600000
17Aug312220
18Sep800001
19Oct612220
20Nov600001

<tbody>
</tbody>

Desired Results - Located on Sheet 2
CD
1JulRedmond
2
Jul
<strike></strike>
<strike></strike>
Redmond
<strike></strike>
3
Jul
<strike></strike>
<strike></strike>
Redmond
<strike></strike>
4Jul<strike></strike>
Redmond
<strike></strike>
5Jul<strike></strike>
Redmond
<strike></strike>
6Jul<strike></strike>
Redmond
<strike></strike>
7
Aug
<strike></strike>
<strike></strike>
Redmond
<strike></strike>
8
Aug
<strike></strike>
<strike></strike>
Redmond
<strike></strike>
9
Aug
<strike></strike>
<strike></strike>
Redmond
<strike></strike>
10
Aug
<strike></strike>
Beijing
11
Aug
<strike></strike>
Dublin
12
Aug
<strike></strike>
Dublin
13
Aug
<strike></strike>
Hyderabad

<tbody>
</tbody>


Here is my formula: =Index(Events, MATCH($C1,'Sheet1'!$A$16:$A$20,0), Match(COUNTIF($C$1:$C1,$C1),Sum(A15:G15),1))

Scenario: Column C is prepopulated by another formula. This new formula would be pasted in D1 and copied down, and return the Event locations (column headers) based on the count of how many times that month has appeared in Column C. If the count of months in Column C exceeds the planned number of events in the first column, then it will sum the next column until the sum is greater than or equal to the count of month.

Logic Check:
CD
1Jul (Row=1,Count=1)(Count <= Sum(col1) = col1)
(1 <= 6) =
Redmond
2
Jul
(
Row=1,
Count
=2)
<strike></strike>
(Count <= Sum(col1) = col1)
(2 <= 6) = Redmond
<strike></strike>
3
Jul
(
Row=1,
Count
=3)
<strike></strike>
(Count <= Sum(col1) = col1)
(3 <= 6) = Redmond
<strike></strike>
4Jul
(
Row=1,
Count
=4)
<strike></strike>
(Count <= Sum(col1) = col1)
(4 <= 6) = Redmond
<strike></strike>
5Jul
(
Row=1,
Count
=5)
<strike></strike>
(Count <= Sum(col1) = col1)
(5 <= 6) = Redmond
<strike></strike>
6Jul
(
Row=1,
Count
=6)
<strike></strike>
(Count <= Sum(col1) = col1)
(6 <= 6) = Redmond
<strike></strike>
7
Aug
(Row=2,Count=1)
<strike></strike>
(Count <= Sum(col1) = col1)
(1 <= 3) = Redmond
<strike></strike>
8
Aug
(Row=2,Count=2)
<strike></strike>
(Count <= Sum(col1) = col1)
(2 <= 3) = Redmond
<strike></strike>
9
Aug
(Row=2,Count=3)
<strike></strike>
(Count <= Sum(col1) = col1)
(3 <= 3) = Redmond
<strike></strike>
10
Aug
(Row=2,Count=4)
(Count > Sum(col1) Therefore (Count <= Sum(col1+col2))
(4 > 3) Therefore (4 <= 3+1) = Beijing
11
Aug
(Row=2,Count=5)
(Count > Sum(col1+col2)) Therefore
(Count <= Sum(col1+col2+col3))
<strike></strike>
(5 > 3+1) Therefore (5 <= 3+1+2) =
Dublin
12
Aug
(Row=2,Count=6)
(Count <= Sum(col1+col2+col3))
(6 <= 3+1+2) =
Dublin
13
Aug
(Row=2,Count=7)
(Count > Sum(col1+col2+col3)) Therefore (Count <= Sum(col1+col2+col3+col4))
(7 <= 3+1+2+2) =
Hyderabad

<tbody>
</tbody>
And so on down the list...
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Maybe...

To make things easier create a helper column in Sheet1 like below (gray area)

A
B
C
D
E
F
G
H
I
15
Redmond​
Beijing​
Dublin​
Hyderabad​
Munich​
Singapore​
Total
16
Jul​
6​
0​
0​
0​
0​
0​
6
17
Aug​
3​
1​
2​
2​
2​
0​
16​
18
Sep​
8​
0​
0​
0​
0​
1​
25​
19
Oct​
6​
1​
2​
2​
2​
0​
38
20
Nov​
6​
0​
0​
0​
0​
1​
45​

<tbody>
</tbody>


Formula in I16 copied down
=SUM(B$16:G16)


Sheet2

C
D
1
Jul​
Redmond​
2
Jul​
Redmond​
3
Jul​
Redmond​
4
Jul​
Redmond​
5
Jul​
Redmond
6
Jul​
Redmond
7
Aug​
Redmond​
8
Aug​
Redmond​
9
Aug​
Redmond​
10
Aug​
Beijing​
11
Aug​
Dublin​
12
Aug​
Dublin
13
Aug​
Hyderabad
14
Aug​
Hyderabad​
15
Aug​
Munich​
16
Aug​
Munich​
17
Sep​
Redmond​
18
Sep​
Redmond​
19
Sep​
Redmond
20
Sep​
Redmond
21
Sep​
Redmond​
22
Sep​
Redmond​
23
Sep​
Redmond​
24
Sep​
Redmond​
25
Sep​
Singapore​
26
Oct​
Redmond
27
Oct​
Redmond
28
Oct​
Redmond​
29
Oct​
Redmond​
30
Oct​
Redmond​
31
Oct​
Redmond​
32
Oct​
Beijing​
33
Oct​
Dublin
34
Oct​
Dublin
35
Oct​
Hyderabad​
36
Oct​
Hyderabad​
37
Oct​
Munich​
38
Oct​
Munich​
39
Nov​
Redmond
40
Nov​
Redmond
41
Nov​
Redmond​
42
Nov​
Redmond​
43
Nov​
Redmond​
44
Nov​
Redmond​
45
Nov​
Singapore​
46

<tbody>
</tbody>



Formula in C1 copied down
=IF(ROWS(C$1:C1)>Sheet1!$I$20,"",INDEX(Sheet1!A$16:A$20,IFERROR(1+MATCH(ROWS(C$1:C1)-1,Sheet1!I$16:I$20),1)))

Array formula in D1 copied down
=IF(C1="","",INDEX(Sheet1!B$15:G$15,MATCH(COUNTIF(C$1:C1,C1)-1,SUBTOTAL(9,OFFSET(INDEX(Sheet1!$A$16:$A$20,MATCH(C1,Sheet1!$A$16:$A$20,0)),,,1,COLUMN($A$1:$G$1)-COLUMN($A$1)+1)))))
Ctrl+Shift+Enter

Hope this helps

M.
 
Upvote 0
Thank you Marcelo! I will give it a try, looks a lot better than what I was able to come up with. I eventually ended up with a helper column as well. Thank you for going above and beyond by providing the C1 formula in addition to the D1 formula!
 
Upvote 0

Forum statistics

Threads
1,215,521
Messages
6,125,308
Members
449,218
Latest member
Excel Master

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