Sumif vs Sumproduct

jlkirk

Active Member
Joined
May 6, 2002
Messages
328
Office Version
  1. 365
In column A I have Account Names (A,B,C); they are listed randomly in rows 1-100. In column B I have dollar amounts (different for each account listed in column A). In each cell in column C I have text that includes the words "SALES" and "SHRS". In each cell in column D there is either an "S" or an "L".

What I would like to do in column F is insert the dollar amounts in column B when (i) the cell in column C contains the words "SALES" and "SHRS", and (ii) the cell in column D contains an "L"

Therefore, for example, if B1 was $100, C1 contained "SALES" and "SHRS" (among other verbiage), and cell D1 contained an "L", then F1 would be populated with $100; if, continuing the example, if D1 contained an "S", cell F1 would be blank or empty.

Any help?

I think its a sumproduct issue, but cant figure out how to use the wildcards.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
are you summing the values - or just copying say from B2 to F2
have text that includes the words "SALES" and "SHRS".
is that an OR or AND as shown

=IF( AND(D1="L", isnumber(Search(C1,"sales",1)),isnumber(Search(C1,"SHRS",1))), B1, "")


Therefore -

A SMALL sample spreadsheet, around 10-20 rows, would help a lot here, with all sensitive data removed, and expected results mocked up and manually entered, with a few notes of explanation.

This will possibly enable a quicker and more accurate solution for you.

MrExcel has a tool called “XL2BB” that lets you post samples of your data and will allow us to copy/paste your sample data into our Excel spreadsheets, saving a lot of time.

You can also test to see if it works ok, in the "Test Here" forum.

OR if you cannot get XL2BB to work, or have restrictions on your PC

then put the sample spreadsheet onto a share

I only tend to goto OneDrive, Dropbox or google docs , as I'm never certain of other random share sites and possible virus.
Please make sure you have a representative data sample and also that the data has been desensitised, remember this site is open to anyone with internet access to see - so any sensitive / personal data should be removed

Make sure you set any share or google to share to everyone
 
Upvote 0
In column A I have Account Names (A,B,C); they are listed randomly in rows 1-100. In column B I have dollar amounts (different for each account listed in column A). In each cell in column C I have text that includes the words "SALES" and "SHRS". In each cell in column D there is either an "S" or an "L".

What I would like to do in column F is insert the dollar amounts in column B when (i) the cell in column C contains the words "SALES" and "SHRS", and (ii) the cell in column D contains an "L"

Therefore, for example, if B1 was $100, C1 contained "SALES" and "SHRS" (among other verbiage), and cell D1 contained an "L", then F1 would be populated with $100; if, continuing the example, if D1 contained an "S", cell F1 would be blank or empty.

Any help?

I think its a sumproduct issue, but cant figure out how to use the wildcards.
I tried this and it seems to work:

=sumif(B1,C1,"*SALES*",C1,"*SHRS*",D1,"L")
 
Upvote 0
you could use

jlkirk

not sure how the sumif() type of formula worked
but would need a SUMIFS() - i suspect a type

SUMIFS()

=sumifs(B1,C1,"*SALES*",C1,"*SHRS*",D1,"L")
and add a date range for Z


BUT do you now what to add up a range and NOT just 1 cell

=SUMIFS(B1,C1,"*SALES*",C1,"*SHRS*",D1,"L",Z1,">="&DATEVALUE("1/1/24"),Z1,"<="&DATEVALUE("31/1/24"))
 
Upvote 0
=SUMIFS(B1,C1,"*SALES*",C1,"*SHRS*",D1,"L",Z1,">="&DATEVALUE("1/1/24"),Z1,"<="&DATEVALUE("31/1/24"))

=IF(AND( Z1>=DATEVALUE("1/1/24"),Z1<=DATEVALUE("31/1/24"),D1="L",ISNUMBER(SEARCH("sales",C1,1)),ISNUMBER(SEARCH("SHRS",C1,1))),B1,"")
 
Upvote 0
SEE A1 AND A2

Book1
ABCDEYZ
11212sales SHRSL1/2/24
212
3
4
5
Sheet1
Cell Formulas
RangeFormula
A1A1=SUMIFS(B1,C1,"*SALES*",C1,"*SHRS*",D1,"L",Z1,">="&DATEVALUE("1/1/24"),Z1,"<="&DATEVALUE("31/1/24"))
A2A2=IF(AND( Z1>=DATEVALUE("1/1/24"),Z1<=DATEVALUE("31/1/24"),D1="L",ISNUMBER(SEARCH("sales",C1,1)),ISNUMBER(SEARCH("SHRS",C1,1))),B1,"")
 
Upvote 0
SEE A1 AND A2

Book1
ABCDEYZ
11212sales SHRSL1/2/24
212
3
4
5
Sheet1
Cell Formulas
RangeFormula
A1A1=SUMIFS(B1,C1,"*SALES*",C1,"*SHRS*",D1,"L",Z1,">="&DATEVALUE("1/1/24"),Z1,"<="&DATEVALUE("31/1/24"))
A2A2=IF(AND( Z1>=DATEVALUE("1/1/24"),Z1<=DATEVALUE("31/1/24"),D1="L",ISNUMBER(SEARCH("sales",C1,1)),ISNUMBER(SEARCH("SHRS",C1,1))),B1,"")
They seem to work...just a question: could you use some form of say "Month(Z1)=1" or "Month(Z1)=Month(AA1)" where AA1 is a date like "January 2024"
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,249
Members
452,623
Latest member
Techenthusiast

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