Sum array with some criteria problem

sasa_z

New Member
Joined
May 18, 2018
Messages
9
I have Sheet1 and Sheet2.

Sheet1
[TABLE="width: 500"]
<tbody>[TR]
[TD]employeeID (c column)[/TD]
[TD]JobID (d column)[/TD]
[TD]result[/TD]
[/TR]
[TR]
[TD]23[/TD]
[TD]1[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Sheet2 (named CSV1)

[TABLE="width: 500"]
<tbody>[TR]
[TD]employeeID (A column)[/TD]
[TD]JobID (D column))[/TD]
[TD]payment1 (X column)[/TD]
[TD]payment2 (BM column)[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]23[/TD]
[TD]1[/TD]
[TD]3334[/TD]
[TD]3454[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

In Result column on sheet1 I want to have sum of columns (payment1,payment2) where values employeeID and JobID are the same in both sheets.

I tried this {=SUM(IF($C5='CSV1'!$A$2:$A$151,$D5='CSV1'!$H$2:$H$151)*('CSV1'!$X$2:$X$151+'CSV1'!$BM$2:$BM$151))} and it worked but when some rows are deleted formula got #ref ! error so I decided to use offset as well
{=SUM(IF(OFFSET($A$1,ROW()-ROW($B$1),1)='CSV1'!$A$2:$A$151,OFFSET($A$1,ROW()-ROW($B$1),2)='CSV1'!$H$2:$H$151)*('CSV1'!$X$2:$X$151+'CSV1'!$BM$2:$BM$151))}

and got #ref ! error with "a value used is of the wrong data type

Any help appreciated
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Control+shift+enter, not just enter:

=SUM(IF(CSV1!$A$2:$A$100=A2,IF(CASV1!$D$2:$D$100=B2,CSV1!$X$2:$X$100+CSV1!$BM$2:$BM$100)))

where A2 = 23 and B2 = 1.
 
Upvote 0
Thank you Aladin for you answer. I tried and it doesn't work. When I tried =IF(CSV1!$A$2:$A$100=A2 it founds only first value in a range, it doesn't proceed further
 
Upvote 0
Thank you Aladin for you answer. I tried and it doesn't work. When I tried =IF(CSV1!$A$2:$A$100=A2 it founds only first value in a range, it doesn't proceed further

Edited for the references, the formula is: In E2 of Sheet1 control+shift+enter, not just enter, and copy down...

=SUM(IF('CSV1'!$A$2:$A$100=C2,IF('CSV1'!$D$2:$D$100=D2,'CSV1'!$X$2:$X$100+'CSV1'!$BM$2:$BM$100)))

This should work as intended.
 
Upvote 0
No, it doesn't work. Of the the problem is IF('CSV1'!$A$2:$A$100=C2 proceed only first value. Try to create simple range in excel and you will see.
 
Upvote 0
No, it doesn't work. Of the the problem is IF('CSV1'!$A$2:$A$100=C2 proceed only first value. Try to create simple range in excel and you will see.

Did you apply control+shift+enter to the formula before copying it down?

Control+shift+enter means: Press down the control and the shift keys at the same time while you hit the enter key. If done with success, Excel itself puts a pair of { and } around the formula in recognition.
 
Upvote 0
Hm. I did literally the same in my excel but not sure why it behaves differently. It just catch first value in a range, not sure about the reason.

By the way, I tried to use offset in your excel but it didn't work. I need to use offset because from time to time, some rows are deleted. Please see below how I used offset.

{=SUM(IF('CSV1'!$A$2:$A$100=OFFSET($C$1,ROW()-ROW($D$1),0),IF('CSV1'!$D$2:$D$100=OFFSET($C$1,ROW()-ROW($D$1),1),'CSV1'!$X$2:$X$100+'CSV1'!$BM$2:$BM$100)))}

Thank you
 
Upvote 0
Hm. I did literally the same in my excel but not sure why it behaves differently. It just catch first value in a range, not sure about the reason.

By the way, I tried to use offset in your excel but it didn't work. I need to use offset because from time to time, some rows are deleted. Please see below how I used offset.

{=SUM(IF('CSV1'!$A$2:$A$100=OFFSET($C$1,ROW()-ROW($D$1),0),IF('CSV1'!$D$2:$D$100=OFFSET($C$1,ROW()-ROW($D$1),1),'CSV1'!$X$2:$X$100+'CSV1'!$BM$2:$BM$100)))}

Thank you

Don't. Try to implement the set up you are given.
 
Upvote 0

Forum statistics

Threads
1,223,957
Messages
6,175,625
Members
452,661
Latest member
Nonhle

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