vendredi 21 juillet 2017

If value = true do a vlookup on a different data set

In sheet 2 I have a list of 2 character codes(country codes) in cell A2 and in cell B2 I have numeric values(postcodes). In sheet 1 I have a larger list of 2 character country codes codes in Cell A2 and postcodes in cell B2 and a city name in Cell C2.

I am trying to use an if function to check if the country code in sheet 2 cell A2 exists in Sheet 1 Cell A2, then if Yes, use a vlookup to pull the city name from sheet 1 corresponding with the postcode in sheet 1 cell B2.

Below returns a result but when checking the results some are incorrect (I think it is due to duplicate country codes.

=IF(ISERROR(MATCH(A2,'Sheet1'!A:A, 0)), "No Match", VLOOKUP(B2,'Sheet1'!B:C,2,FALSE))

Any help is much appreciated!

thanks, Danny

Aucun commentaire:

Enregistrer un commentaire