Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

VLOOKUP formula

How do I get for example in empty box next text box. look image. Thanks


User uploaded fileUser uploaded file

Mac mini, iOS 11.4.1

Posted on Oct 1, 2018 8:33 AM

Reply
Question marked as Best reply

Posted on Oct 1, 2018 11:31 PM

User uploaded file

It makes the formula a bit longer, but it is doable.


The revised formula uses a pair of nested IF statements. Here's the logic:


IF1 is true (nothing in A2), ""(null string), otherwise,

IF2 is true (company is listed), company name fro column 3, otherwise,

(Person's name from column 2)


IF(LEN(A2)<1,"",

IF(LEN(VLOOKUP(A2,Contacts::A:C,3,FALSE))>1,VLOOKUP(A2,Contacts::A:C,3,FALSE),

VLOOKUP(A2,Contacts::A:C,2,FALSE)))


Pastable copy:


IF(LEN(A2)<1,"",IF(LEN(VLOOKUP(A2,Contacts::A:C,3,FALSE))>1,VLOOKUP(A2,Contacts: :A:C,3,FALSE),VLOOKUP(A2,Contacts::A:C,2,FALSE)))


Regards,

Barry

9 replies
Question marked as Best reply

Oct 1, 2018 11:31 PM in response to ryszardb

User uploaded file

It makes the formula a bit longer, but it is doable.


The revised formula uses a pair of nested IF statements. Here's the logic:


IF1 is true (nothing in A2), ""(null string), otherwise,

IF2 is true (company is listed), company name fro column 3, otherwise,

(Person's name from column 2)


IF(LEN(A2)<1,"",

IF(LEN(VLOOKUP(A2,Contacts::A:C,3,FALSE))>1,VLOOKUP(A2,Contacts::A:C,3,FALSE),

VLOOKUP(A2,Contacts::A:C,2,FALSE)))


Pastable copy:


IF(LEN(A2)<1,"",IF(LEN(VLOOKUP(A2,Contacts::A:C,3,FALSE))>1,VLOOKUP(A2,Contacts: :A:C,3,FALSE),VLOOKUP(A2,Contacts::A:C,2,FALSE)))


Regards,

Barry

Oct 1, 2018 12:56 PM in response to ryszardb

Hi ryszardb,


Your question is not clear.


The formula shown is delivering what it is written to do: get a number from 'this row'of column A (of 'this table'), search for that number in the first column of the lookup table—columns A to C of "Contacts", and return the value on the same row of the second column of the lookup table.


The empty cell in row 4 of "Contacts" is read as the numerical value zero.


Your label on column B of "Data" indicates you want both the name and the company name returned to cells in that column. To do that, you will need two VLOOKUP statements in the formula, with their results concatenated into a single value.

User uploaded file

The error triangles mark 'couldn't find' errors. To avoid them, wrap the formula in an IF statement that prevents the VLOOKUPs being called if there is no entry in column A.


The single space separator is added regardless of one of the other cells being empty in the Contacts table.

Note the space in front of "Company 3". There's also a space after "Name 2" in the following row.

Enclosing the formula in TRIM() will remove those spaces.

User uploaded file

Full formula:

TRIM(IF(LEN(A2)<1,"",VLOOKUP(A2,Contacts::A:C,2,FALSE)&" "&VLOOKUP(A2,Contacts::A:C,3,FALSE)))


Core formula in bold, IF 'switch' in normal type, TRIM part in italics.


Regards,

Barry

VLOOKUP formula

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.