Dynamic column range based on dropdown menu

DravenExcel

New Member
Joined
Feb 18, 2020
Messages
6
Office Version
  1. 2016
Platform
  1. Windows
Hi there,

I'm looking for help with a problem in regards to using a dropdown menu for a dynamic summation of periods. I have a drop down menu with P1-P12 in it.

Here is the report that I have to use for the information.

Right now I have been working on by just using SumProduct to get the required totals I need but columns based on the expense numbers. I've tried using Index/match to make the column range dynamic but no luck.

Expense numberP1P2P3P4P5P6P7P8P9P10P11P12
1111​
8,515.41​
11,353.88​
5,676.94​
0​
0​
0​
0​
0​
0​
0​
0​
0​
2222​
6,917.78​
9,223.70​
11,529.63​
9,223.70​
11,529.63​
9,223.70​
9,223.70​
11,529.63​
9,223.70​
9,223.70​
11,529.63​
12,452.00​
3333​
9,527.37​
12,703.16​
15,878.95​
12,703.16​
15,878.95​
12,703.16​
12,703.16​
15,878.95​
12,703.16​
12,703.16​
15,878.95​
17,149.26​
4444​
0​
2,826.64​
4,830.15​
3,864.12​
4,830.15​
966.03​
0​
0​
0​
0​
0​
0​
5555​
0​
0​
0​
0​
2,708.55​
902.85​
0​
0​
0​
0​
0​
0​
6666​
0​
0​
0​
0​
4,533.69​
6,044.93​
6,044.93​
7,556.16​
6,044.93​
6,044.93​
0​
0​
7777​
0​
0​
0​
0​
2,406.78​
4,813.55​
4,813.55​
4,813.55​
0​
0​
0​
0​
5555​
0​
0​
0​
0​
0​
965.29​
1,287.05​
1,608.81​
1,287.05​
1,287.05​
1,608.81​
1,737.52​
4444​
0​
0​
0​
0​
0​
1,206.61​
1,608.81​
2,011.01​
1,608.81​
1,608.81​
2,011.01​
2,171.90​
8888​
0​
0​
0​
0​
0​
0​
0​
0​
0​
2,174.45​
5,436.12​
5,871.01​
6666​
0​
0​
0​
0​
0​
0​
0​
0​
0​
0​
7,556.16​
8,160.65​

My output is as shown below and the formula is =SUMPRODUCT((A15:A25=A29)*B15:M25)

1111​
25546.23​
2222​
120830.5​
3333​
166411.4​
4444​
29544.05​
5555​
13392.98​
6666​
51986.38​
7777​
16847.43​
8888​
13481.58​

As soon as I add in another array to act as the drop down menu the formula stops added and only gives the first number.

Anyone able to help fix this?

Thanks in advance.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Having difficulty using the data provided. Will you upload the same using XL2BB so that the data can be manipulated easily.
 
Upvote 0
What cell is the dropdown in & what do you want to add?
 
Upvote 0
Here is the data in XL2BB format. Sorry for the late reply.

Expense example.xlsx
ABCDEFGHIJKLM
1Expense numberP1P2P3P4P5P6P7P8P9P10P11P12
211118,515.4111,353.885,676.94000000000
322226,917.789,223.7011,529.639,223.7011,529.639,223.709,223.7011,529.639,223.709,223.7011,529.6312,452.00
433339,527.3712,703.1615,878.9512,703.1615,878.9512,703.1612,703.1615,878.9512,703.1612,703.1615,878.9517,149.26
5444402,826.644,830.153,864.124,830.15966.03000000
6555500002,708.55902.85000000
7666600004,533.696,044.936,044.937,556.166,044.936,044.9300
8777700002,406.784,813.554,813.554,813.550000
9555500000965.291,287.051,608.811,287.051,287.051,608.811,737.52
104444000001,206.611,608.812,011.011,608.811,608.812,011.012,171.90
1188880000000002,174.455,436.125,871.01
12666600000000007,556.168,160.65
13
14
15Total ExpensesCheck number P1-P6Dropdown
16111125,546.23Starting PeriodEnding PeriodP1
17222257,648.14P1P6P2
18333379,394.75P3
19444418,523.70P4
2055554,576.69P5
21666610,578.62P6
2277777,220.33P7
2388880.00P8
24P9
25P10
26P11
27P12
Sheet1
Cell Formulas
RangeFormula
D22,D16:D18D16=SUM(B2:G2)
D19,D21D19=SUM(B5:G5)+SUM(B10:G10)
D20D20=SUM(B6:G6)+SUM(B9:G9)
D23D23=SUM(B11:G11)
Cells with Data Validation
CellAllowCriteria
H17List=$K$16:$K$27
F17List=$K$16:$K$27
 
Upvote 0
How about
Excel Formula:
=SUMPRODUCT(($A$2:$A$12=B16)*(MID($B$1:$M$1,2,2)+0>=MID($F$17,2,2)+0)*(MID($B$1:$M$1,2,2)+0<=MID($H$17,2,2)+0)*($B$2:$M$12))
 
Upvote 0
How about
Excel Formula:
=SUMPRODUCT(($A$2:$A$12=B16)*(MID($B$1:$M$1,2,2)+0>=MID($F$17,2,2)+0)*(MID($B$1:$M$1,2,2)+0<=MID($H$17,2,2)+0)*($B$2:$M$12))
Brilliant! I was trying to do an index/match version of this and I never thought of just using mid. Thanks for your help I really appreciate it!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,787
Messages
6,180,950
Members
453,009
Latest member
lorbieckit

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