SumProduct - Multiple Criteria - VBA

IanSavage

New Member
Joined
Mar 16, 2019
Messages
3
I am trying to work on a set of data, where I need to count how many times certain combinations of codes are used. Originally I had just one set of codes to count, but now I have multiple code combinations to count.

Is it possible to combine the two lines of code as below, to work together in VBA? I know they work individually, but now I need something to work with the multiple criteria, plus place the relevant answers in different cells. In total, I have something in the region of 15 'AB' codes and 20'RC' codes.

Worksheets("Count Codes").Range("B2").Value = Worksheets("RC Code Data").Evaluate("SumProduct(--(Left(B4:B1000, 4) = ""AB10""))")
Worksheets("Count Codes").Range("C2").Value = Worksheets("RC Code Data").Evaluate("SumProduct(--(Left(F4:F1000, 4) = ""RC10""))")

I've been scratching my head, and its beating me so far.

Any help will be gratefully appreciated!!

Ian
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
How about
Code:
Sub IanSavage()
   Dim Ary As Variant, x As Variant
   Dim i As Long
   
   Ary = Array("AB10", "AB11", "AB09")
   For i = 0 To UBound(Ary)
   Worksheets("Count Codes").Range("B2").Offset(i).Value = Worksheets("RC Code Data").Evaluate("SumProduct(--(Left($B$4:$B$1000, 4) =" & Chr(34) & Ary(i) & Chr(34) & "))")
   Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,867
Members
449,053
Latest member
Mesh

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