SUMIF/SUMPRODUCT or any formula that can analyze this table

carlboyu

New Member
Joined
May 23, 2018
Messages
3
1fyNBWF
Good day! Below is an image of the data to be consolidated on my summary table.
1fyNBWF


https://imgur.com/1fyNBWF


And here is my format for the table that I will be using.


https://imgur.com/T5vl58i


Here's an overview on how the table works. The table will get the sum of ITEM placed in STORE. I only know on computing it via SUMIF but it takes plenty of time to compute since the summary table will have 39000 rows of ITEM to look on to. Is there any other method to get same result but much faster computing speed?
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hi,

I don't know if there's really a "much faster" way:


Book1
ABCDEFGHMNOPQRS
1STORE 1STORE 2STORE 3STORE 4STORE 1STORE 3STORE 1STORE 2STORE 3STORE 4STORE 5STORE 6
2ITEM 11223113ITEM 181732600
3ITEM 12121223ITEM 2513100
4ITEM 1131311
5ITEM 2311122
6ITEM 3
7ITEM 4
Sheet60
Cell Formulas
RangeFormula
N2=SUMPRODUCT(($B$1:$G$1=N$1)*($A$2:$A$39000=$M2)*$B$2:$G$39000)


N2 formula copied down and across.
 
Upvote 0
You're welcome, welcome to the forum.

Glad you worked it out.
 
Upvote 0
Is there any other method to get same result but much faster computing speed?
Yes, if you are happy to use a macro.
For me, with 40,000 rows of data like your first image, the formula solution suggested takes about 7-8 seconds to recalculate. The macro suggested below took less than half a second.

My assumptions:
- Original data starts at A1 as shown in your image.
- The (blank) table with item numbers and store names only already exists in column M and row 1
- There is nothing in the sheet between the two tables.

Note that my code leaves cells blank in the second table if there is no data but that could be altered to populate those cells with zeroes if required.

If you need help with how to implement the macro, post back, otherwise test in a copy of your workbook.
Code:
Sub AnalyzeTable()
  Dim d As Object
  Dim a As Variant, b As Variant
  Dim i As Long, j As Long, ub2 As Long
  
  Set d = CreateObject("Scripting.Dictionary")
  a = Range("A1").CurrentRegion.Value
  ub2 = UBound(a, 2)
  For i = 2 To UBound(a)
    For j = 2 To ub2
      d(a(i, 1) & "|" & a(1, j)) = d(a(i, 1) & "|" & a(1, j)) + a(i, j)
    Next j
  Next i
  b = Range("M1").CurrentRegion.Value
  ub2 = UBound(a, 2)
  For i = 2 To UBound(b)
    For j = 2 To ub2
      b(i, j) = d(b(i, 1) & "|" & b(1, j))
    Next j
  Next i
  Range("M1").Resize(UBound(b), ub2).Value = b
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,244
Messages
6,170,976
Members
452,372
Latest member
Natalie18

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