misbehaving array

methody

Well-known Member
Joined
Jun 17, 2002
Messages
843
"Hello
In column B under a heading 'letters' I have the numbers 1 2 3 1 in separate cell. In column C under a heading 'cost' I have the numbers 4 5 5 7 in sepate cells. I have named the ranges in columns B and C 'let' and 'cost'. I want a formula for the sum of all those cells in column C which have a '1' in column B. The answer should be 11. When I use an array formula with the curly brackets =SUM(IF(let="1",1,0)*cost) it works. If I put the numbber '1' into a separate cell, say E6 and replace "1" in the formula with E6 it doesn't work. Do you know why as this is what I need to do.
I'd appreciate any thoughts.
methody
 

Some videos you may like

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

jfuoti

New Member
Joined
Mar 26, 2002
Messages
48
The reason is because the array formula needs to have the same # of components in each list. In effect, with an array formula you are looking at ranges of data, when the ranges are different sizes it won't work because you are asking to look at a range >1 cell and a single cell. You would also get an error if let and cost were different amounts of data. To correct this you would have to have the constant "1" be in a similar sized array. Hope this helps.
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
It seems that the entries in let are text, because you have surrounded the 1 with quotes. If the entry of 1 in E6 is also text this array formula will work:

=SUM(IF(let=E6,1,0)*cost)

So format cell E6 as Text before entering a 1.

Contrary to what jfuoti said, Excel will successfully compare an array with a single cell, just as it does with a single number or string.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,967
Messages
5,599,092
Members
414,285
Latest member
excela2z

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
Top