ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Lookup valid combination of multiple cells (https://www.excelbanter.com/excel-worksheet-functions/165253-lookup-valid-combination-multiple-cells.html)

Gerard

Lookup valid combination of multiple cells
 
Is it possible to lookup a valid match of 2 values in separate columns, and
provide the value of a related third column?

Sheet1

Name Code Amount
Ant 003 100
Bil 002 200
Claire 001 300

Sheet2

Full code Amount
Ant003

The Full code in Sheet2 is entered manually and I wish to keep this.

The Amount cell in Sheet2 should lookup the full code (eg Ant003) directly
from the concatenation of the Name and Code fields in Sheet1 (in this case it
should display 100)

Is it possible to retrieve the amount automatically without having to create
a separate lookup table, as this is the current method and I want to lose
this intermediary step?

Toppers

Lookup valid combination of multiple cells
 
Try in the Amount field (B2) on Sheet2:

=SUMPRODUCT(--(Sheet1!$B$2:$B$4=RIGHT(A2,3)),--(Sheet1!$A$2:$A$4=LEFT(A2,LEN(A2)-3)),--(Sheet1!$C$2:$C$4))

This assumes Code is always 3 characters long.

HTH

"Gerard" wrote:

Is it possible to lookup a valid match of 2 values in separate columns, and
provide the value of a related third column?

Sheet1

Name Code Amount
Ant 003 100
Bil 002 200
Claire 001 300

Sheet2

Full code Amount
Ant003

The Full code in Sheet2 is entered manually and I wish to keep this.

The Amount cell in Sheet2 should lookup the full code (eg Ant003) directly
from the concatenation of the Name and Code fields in Sheet1 (in this case it
should display 100)

Is it possible to retrieve the amount automatically without having to create
a separate lookup table, as this is the current method and I want to lose
this intermediary step?


Gerard

Lookup valid combination of multiple cells
 
That's worked! Thank you very much.

Just out of interest, if the code was either:

- Always 2 characters long
- Variable

What impact would this have on the function?

Once again, thanks for your help.

Gerard

"Toppers" wrote:

Try in the Amount field (B2) on Sheet2:

=SUMPRODUCT(--(Sheet1!$B$2:$B$4=RIGHT(A2,3)),--(Sheet1!$A$2:$A$4=LEFT(A2,LEN(A2)-3)),--(Sheet1!$C$2:$C$4))

This assumes Code is always 3 characters long.

HTH

"Gerard" wrote:

Is it possible to lookup a valid match of 2 values in separate columns, and
provide the value of a related third column?

Sheet1

Name Code Amount
Ant 003 100
Bil 002 200
Claire 001 300

Sheet2

Full code Amount
Ant003

The Full code in Sheet2 is entered manually and I wish to keep this.

The Amount cell in Sheet2 should lookup the full code (eg Ant003) directly
from the concatenation of the Name and Code fields in Sheet1 (in this case it
should display 100)

Is it possible to retrieve the amount automatically without having to create
a separate lookup table, as this is the current method and I want to lose
this intermediary step?


Toppers

Lookup valid combination of multiple cells
 
If 2 characters long:

=SUMPRODUCT(--(Sheet1!$B$2:$B$4=RIGHT(A2,2)),--(Sheet1!$A$2:$A$4=LEFT(A2,LEN(A2)-2)),--(Sheet1!$C$2:$C$4))

If the length is variable, then we would have to test for a numeric string
(the code) and determine its length so it's rather more complicated.


"Gerard" wrote:

That's worked! Thank you very much.

Just out of interest, if the code was either:

- Always 2 characters long
- Variable

What impact would this have on the function?

Once again, thanks for your help.

Gerard

"Toppers" wrote:

Try in the Amount field (B2) on Sheet2:

=SUMPRODUCT(--(Sheet1!$B$2:$B$4=RIGHT(A2,3)),--(Sheet1!$A$2:$A$4=LEFT(A2,LEN(A2)-3)),--(Sheet1!$C$2:$C$4))

This assumes Code is always 3 characters long.

HTH

"Gerard" wrote:

Is it possible to lookup a valid match of 2 values in separate columns, and
provide the value of a related third column?

Sheet1

Name Code Amount
Ant 003 100
Bil 002 200
Claire 001 300

Sheet2

Full code Amount
Ant003

The Full code in Sheet2 is entered manually and I wish to keep this.

The Amount cell in Sheet2 should lookup the full code (eg Ant003) directly
from the concatenation of the Name and Code fields in Sheet1 (in this case it
should display 100)

Is it possible to retrieve the amount automatically without having to create
a separate lookup table, as this is the current method and I want to lose
this intermediary step?


Teethless mama

Lookup valid combination of multiple cells
 
In sheet 2:

=SUMPRODUCT(--(Name&Code=A2),Amount)


"Gerard" wrote:

Is it possible to lookup a valid match of 2 values in separate columns, and
provide the value of a related third column?

Sheet1

Name Code Amount
Ant 003 100
Bil 002 200
Claire 001 300

Sheet2

Full code Amount
Ant003

The Full code in Sheet2 is entered manually and I wish to keep this.

The Amount cell in Sheet2 should lookup the full code (eg Ant003) directly
from the concatenation of the Name and Code fields in Sheet1 (in this case it
should display 100)

Is it possible to retrieve the amount automatically without having to create
a separate lookup table, as this is the current method and I want to lose
this intermediary step?


Gerard

Lookup valid combination of multiple cells
 
That works perfectly, thanks.

"Teethless mama" wrote:

In sheet 2:

=SUMPRODUCT(--(Name&Code=A2),Amount)


"Gerard" wrote:

Is it possible to lookup a valid match of 2 values in separate columns, and
provide the value of a related third column?

Sheet1

Name Code Amount
Ant 003 100
Bil 002 200
Claire 001 300

Sheet2

Full code Amount
Ant003

The Full code in Sheet2 is entered manually and I wish to keep this.

The Amount cell in Sheet2 should lookup the full code (eg Ant003) directly
from the concatenation of the Name and Code fields in Sheet1 (in this case it
should display 100)

Is it possible to retrieve the amount automatically without having to create
a separate lookup table, as this is the current method and I want to lose
this intermediary step?



All times are GMT +1. The time now is 03:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com