# SUMPRODUCT problem

#### lmcwrod

##### New Member
Hope somebody can help with the following SUMPRODUCT problem. I have a formula that I want to copy across many cells in a row. The sumproduct formula will match the values in the 2 cells above (criteria 1, criteria 2) with values in a database. However, for some cells, I don't care what value is in criteria 2 (only criteria 1 is relevant for certain cells in this row). Thus, I want it to be able to use a wildcard and have the SUMPRODUCT incorporate the values regardless of what appears for criteria 2 in the database. I am trying to put a '*' in the criteria 2 cell for the cells where I don't care what the criteria 2 value is and have SUMPRODUCT read this wildcard but it's not working out.

Hope the snipit below helps clarify:
AZBABBBCBD
2Column1Column2Column3Column4
3Criteria1ABCD
4Criteria2345ANYVALUE
5Rowshowingsumproductvalues#REF!#REF!#REF!#REF!
MaxPumpCapacity

### Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

#### NBVC

##### Well-known Member
Try:

=IF(BA4="ANYVALUE",COUNTIF(database.xls!A1:A200,BA3),SUMPRODUCT(--(databasefile.xls!A1:A200=BA3),--(databasefile.xls!B1:B200=BA4)))

Note: you can replace "ANYVALUE" in the formula with a null, "" if you want to actually leave Criteria 2 blank.

#### lmcwrod

##### New Member
Thanks, NBVC. For the purpose of clarity, I think I oversimplified the situation. The SUMPRODUCT formula actually reads 3 criteria. 2 of which are above and 1 of which is the first value in each row. I don't think the COUNTIF will work with 2 criteria.

Do you think there is a way to do this with more 2 criteria that must be matched but 1 criteria that matters for some cells but not for all?

#### lmcwrod

##### New Member
Building on the Countif problem, I can simply put an if with 2 sumproduct formulas:
=IF(criteria2=0,sumproduct1,sumproduct2)

#### NBVC

##### Well-known Member
That is exactly what I was going to say.

Replies
3
Views
166
Replies
11
Views
756
Replies
8
Views
494
Replies
6
Views
404
Replies
1
Views
124

1,171,430
Messages
5,875,497
Members
433,131
Latest member
ThatOneDude

### 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.

### Which adblocker are you using?

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

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