array values as sumif criteria in vba

alk3ckwd

New Member
Joined
Feb 6, 2009
Messages
9
Hi I'm trying to come up with a way to represent a formula like:

=SUM(SUMIF(A2:A10,{"a";"b"},B2:B10))

into a dynamic vba statement.

i have an array built programmaticaly through vba with a list of names for different facilities, and i want to sum the number of hours they work. So in the above it be like looking in the range A2:A10 for any of the values in my array ({"a";"b"}) and summing up their hours which are in B2:B10.

I've tried stuff like

Code:
Sheets("Sheet1").Cells(1,1).value = Evaluate("=sum(sumif(Sheet2!C:C," & array & ",Sheet2!D:D)")

but that just gives me a #VALUE! error.

Any help would be much appreciated!
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,223,246
Messages
6,170,987
Members
452,373
Latest member
TimReeks

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