Speed up sumproduct formula.

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,362
Office Version
  1. 2010
Hello,

I am having problem using following formula in cell M6 =SUMPRODUCT(--($E$7:$E$86=K7),--($F$7:$F$86=L7),--($G$7:$G$86=M7)) to copied down to M59000 rows would there be any alternative solution for this problem to speed up please help.

*ABCDEFGHIJKLMNO
1
2
3
4
5n1n2n3n4n5P1P2P3Count
612515421230
7136182414121
81412164816121
9161218424790
106101639461012140
11610192936612200
12610202937610301
136102145492026351
146102344492324271
156102845502021221
166103041452526411
176103136392326291
1820242737392636371
192025344245912150
2020263536421516180
2120273036434560
2220273446502526291
2320274143502728292
2423242634502325321
2523242737471827391
266222425362728292
276222629483536370
2818273943473450
2918283946487890
3019263545491213140
3119323537441718590
3219363842462732450
3320212231453132381
3420212632462024260
352021273340510150
3625262949501213140
3725264144472732460
3825273135431214160
3927282934432027411
4027283146474647480
4127293739491516170
4227313342502337380
4328293948502227320
44282940465089100
4523253237421112130
4623262937401415160
4723263241451819200
4820283542431920210
4920373944502324251
5023242531442728312
5123242633422731370
5226343739492731332
5326363738422930321
542728293443610191
5527283146473742450
5627293739492427320
5727313342503537420
58282939485059120
592829404650715220
602830424549912150
6129303234463536370
622933394144122270
63313238404256120
6412490
652326291
661213140
674243440
684546470
691519200
704549500
711926351
72610281
732728292
742728312
752829392
763537420
7759120
781112130
791415160
801819200
811213140
822027341
833234460
843738420
853948500
86
87
88
89

For example the sample image is attached.

Thank you all.

I am using Excel 2000

Regards,
Moti
 

Attachments

  • Fast Formula.png
    Fast Formula.png
    99 KB · Views: 7

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
That formula does not make sense, are you sure it's the correct formula?
 
Upvote 0
Formula in cell M6 =SUMPRODUCT(--($E$7:$E$86=K7),--($F$7:$F$86=L7),--($G$7:$G$86=M7))
Alternate formula in cell M6
=COUNTIFS($E$7:$E$86,K7,$F$7:$F$86,L7,$G$7:$G$86,M7)
 
Upvote 0
Try this macro

VBA Code:
Sub aTest()
    Dim vData As Variant, vSearch As Variant, vResult As Variant
    Dim i As Long, j As Long, lCounter As Long
    
    vData = Range("D6:F" & Cells(Rows.Count, "D").End(xlUp).Row)
    vSearch = Range("J6:L" & Cells(Rows.Count, "J").End(xlUp).Row)
    vResult = Range("M6:M" & Cells(Rows.Count, "J").End(xlUp).Row)
    
    For i = 1 To UBound(vSearch, 1)
        lCounter = 0
        For j = 1 To UBound(vData, 1)
            If vData(j, 1) = vSearch(i, 1) Then
                If vData(j, 2) = vSearch(i, 2) Then
                    If vData(j, 3) = vSearch(i, 3) Then lCounter = lCounter + 1
                End If
            End If
        Next j
        vResult(i, 1) = lCounter
    Next i
    Range("M6:M" & Cells(Rows.Count, "J").End(xlUp).Row) = vResult
End Sub

Hope this helps

M.
 
Upvote 0
Solution
That formula does not make sense, are you sure it's the correct formula?
Sorry Fluff, You are correct I added wrong formula the below is the correct in cell M6 and copied down to M59000.

Thank you for the observation.

VBA Code:
M6=SUMPRODUCT(--($D$6:$D$85=J6),--($E$6:$E$85=K6),--($F$6:$F$85=L6))

Kind Regards,
Moti
 
Upvote 0
Thanks for that, try Marcelo's macro, as I don't think you will get anything better than your formula for xl 2000
 
Upvote 0
Try this macro

VBA Code:
Sub aTest()
    Dim vData As Variant, vSearch As Variant, vResult As Variant
    Dim i As Long, j As Long, lCounter As Long
   
    vData = Range("D6:F" & Cells(Rows.Count, "D").End(xlUp).Row)
    vSearch = Range("J6:L" & Cells(Rows.Count, "J").End(xlUp).Row)
    vResult = Range("M6:M" & Cells(Rows.Count, "J").End(xlUp).Row)
   
    For i = 1 To UBound(vSearch, 1)
        lCounter = 0
        For j = 1 To UBound(vData, 1)
            If vData(j, 1) = vSearch(i, 1) Then
                If vData(j, 2) = vSearch(i, 2) Then
                    If vData(j, 3) = vSearch(i, 3) Then lCounter = lCounter + 1
                End If
            End If
        Next j
        vResult(i, 1) = lCounter
    Next i
    Range("M6:M" & Cells(Rows.Count, "J").End(xlUp).Row) = vResult
End Sub

Hope this helps

M.
Marcelo Branco, your macro really is a time saver and a best solution for my version, ? also I am 100% agree with @Fluff as he said "Marcelo's macro, as I don't think you will get anything better than your formula for xl 2000"

I appreciate your kind help. Good Luck!

Kind Regards,
Moti :)
 
Upvote 0

Forum statistics

Threads
1,215,024
Messages
6,122,729
Members
449,093
Latest member
Mnur

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