Need help to solve this syntax? contain IF and VLOOKUP

Copper Contributor

Hi guys.. this is my first post on here.. I have problem to solve this syntax.. here the scenarios: 

1. write a word on cell A1 for example Harry or Theo or Tiger 

2. then I have a table like this start on cell A5

charvalue
H1
HA1
TH2
THE2
T3

3. on cell A3 I want to know the value of the character with this conditions, if 2 char from left contain letters TH value 2, but if not contain TH will try to value just the first char from left so it will contain T and the value 3.

so I make syntax like this:

=IF(A1<>"";VLOOKUP(LEFT(A1;2);A5:B10;2;FALSE);VLOOKUP(LEFT(A1;1);A5:B10;2;FALSE))

 

but the result just TRUE and FALSE not value 1 or 2 or 3

 

so.. can all of you help me fix the syntax?

 

PS: anyway can you tell me how to just take the 2nd and 3rd char from right regardless of the total letters/char

 

PSS: sorry for may bad English

1 Reply

@kangdede 

Try this:

 

=IFERROR(IF(A1<>"";VLOOKUP(LEFT(A1;2);A5:B10;2;FALSE));VLOOKUP(LEFT(A1;1);A5:B10;2;FALSE))

 

 

Regarding taking "the 2nd and 3rd char from right" from a text string perhaps this:

 

=LEFT(RIGHT(A1,3),2)

 

Let's say the text string is "abcdef", then the formula will return "de".