Home » excel » Excel, Vlookup/IF/else

Excel, Vlookup/IF/else

Posted by: admin May 14, 2020 Leave a comment


I want to do a vlookup/if statement that follows the following logic:

Input to col F : If A:A = a , b , c, d , e  then 'name' & col B:B, C:C, D:D else 'name2'

Edit: Maybe a mapping table could help, the logic I want is, In A2, if the data is a,b,c,d or e then return a string + concatentation of B2,C2,D2 else return another string.

Sample Data, Col E here is the output I would like.

| Stack | xx | yy | zz | Coolxxyyzz |
| Over  | aa | bb | cc | Coolxxyyzz |
| Flow  | dd | ee | ff | Coolxxyyzz |
| Super | gg | hh | ii | NotCool    |
| User  | ll | mm | nn | NotCool    |

Conditions being Stack, Over, Flow are the ones I want to return a string and concatenate of B:D. If it is not Stack, Over,Flow return another string.

adding some images to show error:

enter image description here

enter image description here

How to&Answers:

① Hardcoded example formulas:




② Lookup table – easier to maintain than the above as only change in one place.

If you want a lookup table, rather than hardcoding the array {"Stack","Over","Flow"}, you can create a dynamic named range.

  1. Put your list of terms to match on in a separate column, let’s say from G1.
  2. Press Ctrl+F3 to open the name manager
  3. Add new item. Name: includeTerms RefersTo:=OFFSET(Sheet1!$G$1,0,0,COUNTA(Sheet1!$G:$G),1). This named range will automatically extend when ever you add more rows immediately below the existing terms. No need to edit the formula.
  4. Refer to includeTerms in place of the array,{"Stack","Over","Flow"}.

Dynamic named range

You can substitute the named range into my last 2 formulas above, or even use other formulas, such as:

=IF(ISERROR(MATCH(A1,includeTerms,0)),"NotCool","Cool" &B1&C1&D1)


Examples of these in sheet

*Formulas indicated in column F and terms to match on in column G):

Formulas in sheet

Note: Using OR is probably the least preferred for future maintenance.


EDIT #1:

This formula works for the example given:

=IF(OR(A1="stack",A1="over",A1="flow"),"COOL"&B1&C1&D1&E1,"NOT COOL")


Google Sheets allows for vlookup to return multiple values


However excel does not have this built in functionality, you will have to break up the return into separate parts. I think formula below gives an example of what you would like to see: