# Issue with If and VLOOKUP functions in two sheets of data

I'm struggling to write down the correct function to perform a calculation in excel. In my first sheet, I have a list of towns in Albania, with a corresponding letter "U" or "R" if they are located either in an urban or rural environment. In sheet 2, I have the corresponding literacy rate of either rural or urban environments for a set of countries, including Albania. Therefore, in Sheet 1, under "Literacy Rate %" I'd like to attribute for each Albanian town an urban or rural literacy rate using the values of sheet 2. I was combining if function and vlookup but I'm failing somewhere... My data is illustrated in this picture :

• what have you tried so far? And why use a `VLOOKUP` if you ony use the data from Albania and no other country? – cybernetic.nomad May 6 '19 at 13:06
• @cybernetic.nomad I've found out how to do it. I did: =IF("townA="R";VLOOKUP(ISOCODE;Sheet2"Literacy rate for rural";)VLOOKUP(ISOCODE;"literacy rate for urban")) – user156 May 7 '19 at 10:31
• And it works alright. I used VLOOKUP as I am focusing on other countries as well, Albania was just to illustrate the example. Thanks for your input – user156 May 7 '19 at 10:32

``````=IFERROR(VLOOKUP(\$A3,'Sheet2'!\$A\$2:\$D\$7,IF(I3="R",4,IF(I3="U",3,0)),0),"MISSING INFO")