Sue,
Having slept on it I think that my suggestion was not a bad idea - it was a
TERRIBLE idea. Not only does it have the failing listed previously but it
also returns wrong results if the order of Order Numbers is not the same in
both sheets.
I would *strongly* recommend that you use a "Helper" column in Database 3.
I used Column G but any column will do and if you want you can hide the
"Helper" column.
In G2 of Database 3 enter the formula:
=IF(A2="","",VLOOKUP(A2,'Database 2'!$A$2:$B$30,2,FALSE))
and copy down as far as required.
Then enter a list of Customer Names in Column H starting from H2
The "Billed" formulas are OK because they only reference Database 2 but
change the other formulas as follows:
In the same Row as the Billed Formulas enter:
Paid -
Number of Orders:
=SUMPRODUCT(('Database 3'!$G$2:$G$300=H2)*('Database 3'!$B$2:$B$300="Paid"))
Total Billed Amount:
=SUMPRODUCT(('Database 3'!$G$2:$G$300=H2)*('Database
3'!$B$2:$B$300="Paid")*'Database 3'!$C$2:$C$300)
Rejected -
Number of Orders:
=SUMPRODUCT(('Database 3'!$G$2:$G$300=H2)*('Database
3'!$B$2:$B$300="Rejected"))
Total Billed Amount:
=SUMPRODUCT(('Database 3'!$G$2:$G$300=H2)*('Database
3'!$B$2:$B$300="Rejected")*'Database 3'!$C$2:$C$300)
The ranges are Absolute so that you can drag down on the fill handle for the
other Customer Names in Column H.
I have deliberately left the Formulas in Column G so that they will return a
#N/A error if no match is found. This is because if it returned an empty
string then the above formulas would ignore that entry and thus again return
a wrong result. As it is the above formulas will echo the #N/A errors
returned by Column G.
My apologies if I have caused any confusion.
--
HTH
Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings
[email protected]
Replace @mailinator.com with @tiscali.co.uk