Complex VLOOKUP with LEN formula

NJS1982

Board Regular
Joined
Sep 24, 2009
Messages
183
Office Version
  1. 365
Platform
  1. Windows
Hi all,
I have a formula that goes like this:

=IF(A12604="","",
IF(LEN(VLOOKUP(A12604,'Org Postcodes'!$A$1:$P$105190,MATCH("ORGANISATION_POSTCODE",'Org Postcodes'!$A$1:$P$1,0),0))
+LEN(VLOOKUP(A12604,'Org Postcodes'!$A$1:$P$105190,MATCH("PROJECT_CONTACT_POSTCODE",'Org Postcodes'!$A$1:$P$1,0),0))=0,W12604,
IF(LEN(VLOOKUP(A12604,'Org Postcodes'!$A$1:$P$105190,MATCH("ORGANISATION_POSTCODE",'Org Postcodes'!$A$1:$P$1,0),0))>1,
VLOOKUP(A12604,'Org Postcodes'!$A$1:$P$105190,MATCH("ORGANISATION_POSTCODE",'Org Postcodes'!$A$1:$P$1,0),0),
VLOOKUP(A12604,'Org Postcodes'!$A$1:$P$105190,MATCH("PROJECT_CONTACT_POSTCODE",'Org Postcodes'!$A$1:$P$1,0),0))))

But it doesn't seem to work :(

I am trying to say this:

1) If cell A12604 is blank, make this cell blank: =IF(A12604="","",

2) If cell A12604 isn't blank, lookup the LEN values of the two cells matching A12604 on the 'Org Postcodes' data range, if together they equal zero, provide the result of W12604: IF(LEN(VLOOKUP(A12604,'Org Postcodes'!$A$1:$P$105190,MATCH("ORGANISATION_POSTCODE",'Org Postcodes'!$A$1:$P$1,0),0))
+LEN(VLOOKUP(A12604,'Org Postcodes'!$A$1:$P$105190,MATCH("PROJECT_CONTACT_POSTCODE",'Org Postcodes'!$A$1:$P$1,0),0))=0,W12604,

3) If cell A12604 isn't blank, lookup the LEN values of the Org Postcode cell matching A12604 on the 'Org Postcodes' data range, if this is greater than 1 (as in it isn't blank and has an entry), provide me with the value of this 'Organisation Postcode' lookup value:
IF(LEN(VLOOKUP(A12604,'Org Postcodes'!$A$1:$P$105190,MATCH("ORGANISATION_POSTCODE",'Org Postcodes'!$A$1:$P$1,0),0))>1,
VLOOKUP(A12604,'Org Postcodes'!$A$1:$P$105190,MATCH("ORGANISATION_POSTCODE",'Org Postcodes'!$A$1:$P$1,0),0),

4) If the value is however zero, then provide the value of the Project_Contact_Postcode instead (as if this was zero, then point 2 above would work first and provide the W cell value instead of this one):
VLOOKUP(A12604,'Org Postcodes'!$A$1:$P$105190,MATCH("PROJECT_CONTACT_POSTCODE",'Org Postcodes'!$A$1:$P$1,0),0))))
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
the match() function will only give you the position within the array, not the content.

you need to combine it with the index() function for the content in order to match them
 
Upvote 0
Oh crikey, is it that complicated?
If I give a very simple example below...I can't believe I can't nest a formula to look at three cells independently :(

Which one to use?OrgPCLoc1
OrgL22 3NRL6 0GQL3 8DL
OrgL11 3NRL6 0GQL3 8DL
PCL6 0GQL3 8DL
OrgL11 3NRL6 0GQL3 8DL
Loc1L3 8DL
OrgL11 3NRL6 0GQL3 8DL

<colgroup><col><col span="3"></colgroup><tbody>
</tbody>
 
Upvote 0
something like this?


Excel 2013/2016
ABCDEF
1OrgPCLoc1Which one to use?
2OrgL22 3NRL6 0GQL3 8DLL22 3NR
3OrgL11 3NRL6 0GQL3 8DLL11 3NR
4PCL6 0GQL3 8DLL6 0GQ
5OrgL11 3NRL6 0GQL3 8DLL11 3NR
6Loc1L3 8DLL3 8DL
7OrgL11 3NRL6 0GQL3 8DLL11 3NR
Sheet5
Cell Formulas
RangeFormula
F2=INDEX(B2:D2,MATCH($A2,$B$1:$D$1,0))
 
Last edited:
Upvote 0
No, not really. Sorry I have not explained - column A in this example does not exist. I simply added it to demonstrate which one should be shown, say in column F.
The lookup is against a unique number and the table array is massive (>100k lines).
 
Upvote 0
something like this?


Excel 2013/2016
ABCDEF
1OrgPCLoc1Which one to use?
2OrgL22 3NRL6 0GQL3 8DLL22 3NR
3OrgL11 3NRL6 0GQL3 8DLL11 3NR
4PCL6 0GQL3 8DLL6 0GQ
5OrgL11 3NRL6 0GQL3 8DLL11 3NR
6Loc1L3 8DLL3 8DL
7OrgL11 3NRL6 0GQL3 8DLL11 3NR
Sheet5
Cell Formulas
RangeFormula
F2=INDEX(B2:D2,MATCH($A2,$B$1:$D$1,0))

ok, would you explain how do you come up with Org in A2 and Loc1 in A6 as examples
 
Upvote 0

Forum statistics

Threads
1,215,470
Messages
6,124,992
Members
449,201
Latest member
Lunzwe73

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
Back
Top