PDA

View Full Version : SUMIFS with Multiple criteria using Variables



simora
11-24-2020, 06:21 PM
Trying to create a VBA macro using SUMIFS with Multiple criteria:


eg =SUMIFS(D2:D1940,B2:B1940,"Framing",G2:G1940,"Labor" )
Because this formula will be replicated in a large range;


I want to replace "Framing" in the sample formula with Whatever value is in Column AA [ Offset(0, -1) ] as long as its NOT EMPTY/ IsBLANK
AND
I want to replace "Labor" with Whatever value is in Row 3 of that Column


Then I will move on to Column AC and so on.


See Attached Worksheet

p45cal
11-25-2020, 03:58 AM
You don't need vba. Change the formula in AB4 to:

=SUMIFS($D$2:$D$1940,$B$2:$B$1940,$AA4,$G$2:$G$1940,AB$3)
Copy down and across.

simora
11-26-2020, 12:49 PM
Thanks p45cal:

Your formula worked as expected on a worksheet. The reason why I was looking at VBA is because other rows will be added, and a few other considerations.

p45cal
11-26-2020, 02:40 PM
Make that into a proper Excel table, when you add remove rows the formulae will add/remove themselves.

simora
11-30-2020, 01:12 PM
p45cal:

I used Named ranges and implemented the VBA with some minor changes.

Thanks