Sumproduct of unique values in multiple ranges

Dan5977

Board Regular
Joined
Aug 7, 2008
Messages
108
Office Version
  1. 2010
Hi guys,

Hope you can help. I have a rather complicated (by my standards) spreadsheet and am stuck at this point. Example of type of problem shown below.

sgqzq1.jpg


So I have 3 ranges of data which each have a quantity and a length. I want to create from these ranges a list of unique values with the total quantity required of each value (as shown). Inputs on any column may be blank but where there is a length, there will be an adjacent quantity to the left.

I'm using Excel 2010.

As always, any assistance would be appreciated.

Thanks,

Dan.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
QtyLengthQtyLengthQtyLength
13500130001980
2302011000
2302011000
2350011243
22500
13500
7
Desired Result
43500
13000
43020
1980
21000
11243
22500

<tbody>
</tbody>

Add the following code for ARRAYUNION function to your workbook, using Alt+F11.

Now define LenghtData by means of Formulas | Name Manager as referring to:
Rich (BB code):
=arrayunion(Sheet1!$B$2:$B$7,Sheet1!$D$2:$D$4,Sheet1!$F$2:$F$6)

And define Ivec as referring to:
Rich (BB code):
=ROW(INDIRECT("1:"&COLUMNS(LengthData)))

A11, just enter and copy down:
Rich (BB code):
=IF($B11="","",SUMIF($B$2:$F$7,$B11,$A$2:$E$6))

B11, control+shift+enter, not just enter, and copy down:
Rich (BB code):
=IF(ROWS($B$11:B11)<=$A$9, INDEX(LengthData,
  SMALL(IF(FREQUENCY(IF(LengthData<>"", 
  MATCH("~"&LengthData,LengthData&"",0)),Ivec),Ivec),
  ROWS($B$11:B11))),"")

Addendum. See the workbook that implements the set up of above:
https://dl.dropboxusercontent.com/u/65698317/Dan5977 unque items of a multicolumn range.xlsm

My FREQUENCY CALC in equivalent to $A$9 on the spreadsheet is returning a #NAME? error. I copied Aladin's formula from that cell on the dummy sheet and adjusted the lookup cell accordingly.

Could this be a version issue? I'm using Excel2010. My best guess is that it doesn't know what arrayunion refers to.

Any ideas?
 
Upvote 0
My FREQUENCY CALC in equivalent to $A$9 on the spreadsheet is returning a #NAME? error. I copied Aladin's formula from that cell on the dummy sheet and adjusted the lookup cell accordingly.

Could this be a version issue? I'm using Excel2010. My best guess is that it doesn't know what arrayunion refers to.

Any ideas?

I have no idea what you have been doing. Did you add the ARRAYUNION code to your workbook if you are not using the one I posted?
 
Upvote 0
I have no idea what you have been doing. Did you add the ARRAYUNION code to your workbook if you are not using the one I posted?

Yes. I copied it from the workbook you kindly made into mine. It feels like I'm so close. All the formulas and arrays are in and amended to suit the actual cells. There must just be one issue causing the #NAME? error. I think it relates to arrayunion. It's either that or LengthData but LengthData is defined as you stated too. Everything is spelt correctly and consistently.

Hopefully with a fresh start in the morning it will be more obvious for me!
 
Upvote 0
Yes. I copied it from the workbook you kindly made into mine. It feels like I'm so close. All the formulas and arrays are in and amended to suit the actual cells. There must just be one issue causing the #NAME? error. I think it relates to arrayunion. It's either that or LengthData but LengthData is defined as you stated too. Everything is spelt correctly and consistently.

Hopefully with a fresh start in the morning it will be more obvious for me!

Run Alt+F11.
Choose This Workbook.
Run Insert | Module
Copy the VBA code for ARRAYUNION and paste it into the module pane.
Run File | Close and Return to Microsoft Excel.

If #NAME? still occurs, some definition must be missing.
 
Upvote 0
It works!

Thanks so much for your help and your patience. It's really appreciated.
 
Upvote 0

Forum statistics

Threads
1,217,419
Messages
6,136,529
Members
450,019
Latest member
excelguy2024

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