Excel - Calculating formula taking too long. Is there an alternative to the below formula.

mrsushi

Board Regular
Joined
Nov 18, 2006
Messages
180
Office Version
  1. 2010
I have the below formula which references another sheet and returns the total summary value on sheet lp99. However, the sheet(Paste LP99) has over 200,000 lines of data and the calculation takes near enough 45min - 1 hour to calculate. Is there a alternative which can be used in order to speed up the calculation? Ive heard arrays could work but not used these before?


SUMIF('PASTE LP99'!A:A, A43, 'PASTE LP99'!L:L)
SUMIF('PASTE LP99'!A:A, A43, 'PASTE LP99'!V:V)


Any help would be much appreciated

Many thanks
M
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
And how long takes:
SUMIF('PASTE LP99'!A1:A200000, A43, 'PASTE LP99'!L1:L200000)
 
Upvote 0
I don't think you'll find a faster formula than sumif.
How many cells do you have those formulae in?
 
Upvote 0
I don't think you'll find a faster formula than sumif.
How many cells do you have those formulae in?
Worksheet 1 in Column A has 55K ID's, WorkSheet 2 has 250,000 rows of data in Column L
 
Upvote 0
Ouch, you could possibly use a macro, but that would not update automatically if the data changed.
 
Upvote 0
Ouch, you could possibly use a macro, but that would not update automatically if the data changed.
I've incorporated the formula into a macro, however, that makes no difference to the speed. I heard arrays could solve this calculation issue?
 
Upvote 0
Incorporating that formula into a macro, would be even worse than using the formula.
Maybe something like
VBA Code:
Sub mrsushi()
   Dim Ary As Variant
   Dim Dic As Object
   Dim r As Long
   
   Set Dic = CreateObject("Scripting.dictionary")
   With Sheets("PASTE LP99")
      Ary = .Range("A2:L" & .Range("A" & Rows.Count).End(xlUp).Row).Value2
   End With
   For r = 1 To UBound(Ary)
      Dic(Ary(r, 1)) = Dic(Ary(r, 1)) + Ary(r, 12)
   Next r
   With Sheets("sheet1")
      Ary = .Range("A2:B" & .Range("A" & Rows.Count).End(xlUp).Row).Value2
   End With
   For r = 1 To UBound(Ary)
      Ary(r, 2) = Dic(Ary(r, 1))
   Next r
   Sheets("Sheet1").Range("A2").Resize(UBound(Ary), 2).Value = Ary
End Sub
Change sheet1 name to match your sheet & this will put the result of the sumif in col B
 
Upvote 0
Incorporating that formula into a macro, would be even worse than using the formula.
Maybe something like
VBA Code:
Sub mrsushi()
   Dim Ary As Variant
   Dim Dic As Object
   Dim r As Long
  
   Set Dic = CreateObject("Scripting.dictionary")
   With Sheets("PASTE LP99")
      Ary = .Range("A2:L" & .Range("A" & Rows.Count).End(xlUp).Row).Value2
   End With
   For r = 1 To UBound(Ary)
      Dic(Ary(r, 1)) = Dic(Ary(r, 1)) + Ary(r, 12)
   Next r
   With Sheets("sheet1")
      Ary = .Range("A2:B" & .Range("A" & Rows.Count).End(xlUp).Row).Value2
   End With
   For r = 1 To UBound(Ary)
      Ary(r, 2) = Dic(Ary(r, 1))
   Next r
   Sheets("Sheet1").Range("A2").Resize(UBound(Ary), 2).Value = Ary
End Sub
Change sheet1 name to match your sheet & this will put the result of the sumif in col B
the sheet1 where my formula is to return the value of the sumifs is in Column AA (starts from AA2). Which parts of the above code need to be changed pls?

Sheets("Sheet1").Range("A2").Resize(UBound(Ary), 2).Value = Ary
to be changed to
Sheets("Sheet1").Range("A2").Resize(UBound(Ary), 27).Value = Ary

Any others i need to change pls?
 
Upvote 0
How about
VBA Code:
Sub mrsushi()
   Dim Ary As Variant, Oary As Variant
   Dim Dic As Object
   Dim r As Long
   
   Set Dic = CreateObject("Scripting.dictionary")
   With Sheets("PASTE LP99")
      Ary = .Range("A2:L" & .Range("A" & Rows.Count).End(xlUp).Row).Value2
   End With
   For r = 1 To UBound(Ary)
      Dic(Ary(r, 1)) = Dic(Ary(r, 1)) + Ary(r, 12)
   Next r
   With Sheets("sheet1")
      Ary = .Range("A2", .Range("A" & Rows.Count).End(xlUp)).Value2
      Oary = .Range("AA2:AA" & .Range("A" & Rows.Count).End(xlUp).Row).Value2
   End With
   For r = 1 To UBound(Ary)
      Oary(r, 1) = Dic(Ary(r, 1))
   Next r
   Sheets("Sheet1").Range("AA2").Resize(UBound(Oary)).Value = Oary
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,364
Messages
6,124,507
Members
449,166
Latest member
hokjock

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