SOS! how do I write a customized function to do multiple-value lookupin Excel 2007?

L

LunaMoon

I have two regions in exact same places of sheet 1 and sheet 2,
I want to find all cells in the region in sheet 1, with cell
content equal to 0,
and then add the numbers at the corresponding locations in the region
in sheet 2 up.
For example, let's say in the region in sheet 1,
there are multiple locations where the cell content = 0:
A1,
B3,
C4,
D2,
etc...
I would like to obtain sum(sheet2!A1, sheet2!B3, sheet2!C4, sheet2!
D2), etc.
How do I do that?
I want to write a user customized function for that: The regions in
sheet1 and sheet2 are fixed to be D7 to Z20.
So the first step is to find all cells in sheet1 in D7 to Z20 with
values=0, and then add up all such cells in sheet2...
How to do that? I am a green hand in using Excel/VBA...
Thanks a lot!
 
T

T. Valko

You can do this with built-in functions quite easily.

Does the range to sum, Sheet2D7:Z20, contain only numeric data (empty cells
would be OK)?

Will any of the cells in the criteria range, Sheet1D7:Z20 be empty? Empty
cells evalaute as 0.

The general formula to this would be:

=SUMPRODUCT((Sheet1!D7:Z20=0)*Sheet2!D7:Z20)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top