Forum Discussion
VLOOKUP help
In the attached file, the formulas are as follows:
1. To assign a unique Reference to each Account, the formula starting in E2 is:
=IF(COUNTIF(B$2:B2,B2)=1,
MAX(E$1:E1)+1,
VLOOKUP(B2,B$1:E1,4,0))
2. To create a distinct list of Accounts, sorted in ascending order, the formula starting in G2 is:
=IFERROR(LOOKUP(PI(),
1/(COUNTIF(AccountsEntered,">="&AccountsEntered)=MAX(INDEX(
COUNTIF(AccountsEntered,">="&AccountsEntered)*(COUNTIF(G$1:G1,AccountsEntered)=0),0))),
AccountsEntered),"")
3. To create a list of sequential numbers corresponding to the number of entries to the selected Account in J3, the formula starting in I5 is:
=IF(ROW()-4>COUNTIF(AccountsEntered,J$3),
"",
SUM(I4,1))
4. To create a list of Debit entries to the selected Account in J3, the formula starting in J5 is:
=IFERROR(IF(LOOKUP(PI(),
2/(1/ROW(AccountsEntered)=SUMPRODUCT(LARGE(
1/ROW(AccountsEntered)*(AccountsEntered=$J$3),$I5))),
DebitsEntered)=0,"",
LOOKUP(PI(),
2/(1/ROW(AccountsEntered)=SUMPRODUCT(LARGE(
1/ROW(AccountsEntered)*(AccountsEntered=$J$3),$I5))),
DebitsEntered)),"")
5. To create a list of Credit entries to the selected Account in J3, the formula starting in K5 is:
=IFERROR(IF(LOOKUP(PI(),
2/(1/ROW(AccountsEntered)=SUMPRODUCT(LARGE(
1/ROW(AccountsEntered)*(AccountsEntered=$J$3),$I5))),
CreditsEntered)=0,"",
LOOKUP(PI(),
2/(1/ROW(AccountsEntered)=SUMPRODUCT(LARGE(
1/ROW(AccountsEntered)*(AccountsEntered=$J$3),$I5))),
CreditsEntered)),"")
6. To calculate the balance of the selected Account in J3, the formula in K3 is:
=ABS(SUM(DebitEntries)-SUM(CreditEntries))
Note that all named ranges are dynamic, such that you can add (or delete) entries without need to modify any of the formulas.