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

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

I often find that breaking out each section of your formula into separate columns is a good way to debug.
I would put the ISERROR(MATCH(A2,'Sheet1'!A:A, 0) in one column and the VLOOKUP in the next column and then put an if statement in the third column to calculate the outcome. Then try and figure out which part isn't doing what you expect it to be doing.

Related

Reference data from a range on one sheet to individual cells on another based on neighboring cell value (Excel 365)

Sheet 1 will be references to individuals based on unique identifiers, such that column A will be their name and column B will have the identifier.
Sheet 2 will be an imported list of all individuals in our data set, such that column A is their name and column B is the identifier.
The goal is to be able to fill cells in Sheet 1 Column A based off of values entered in Sheet 1 Column B, by referring to Sheet 2 Column B., i.e. if the column B values match between sheets, I want the neighboring value in Column A to be copied over.
I'm a novice at this, but I don't think CONCATENATE is what I'm looking for, so the closest I've gotten is:
=IF($B:$B=Sheet2!$B:$B,Sheet2!$A:$A)
which results in a SPILL error, because I think my formula is trying to display multiple reference cells of data in one destination cell, whereas a formula such as
=IF(B3=Sheet2!B3, Sheet2!A3)
returns expected results, but is too limited for my purposes, in that it would be potentially faster to just manually enter the data, at that rate.
Trying to simplify, I'll have a sheet that has say 100 people in it, with identifiers 1 through 100. If I punch in their identifier in a separate sheet, I'm looking for their name to be displayed in a neighboring cell, or at least to have their name returned in the same cell, i.e. I enter "90" in Sheet1A1 or Sheet1B1 and it gives me "John Doe" in A1, which is the value of Sheet2B90 that's associated with the number "90" that is in Sheet2A90.
So VLOOKUP does work with some wrangling, but XLOOKUP was the ultimate solution to what I needed. A formula such as
=XLOOKUP(A13,$A$1:$A$10,$B$1:$C$10,NONE)
Would return data from B1 through B10 and C1 through C10 to elsewhere in the sheet, in this case next to a lookup cell A13 into cells B13 and C13, if the value in A13 appears within the lookup array of A1 through A10. Locking the cells with $ allows the formula to be dragged down a range of lookup cells without Excel incrementing the values of the lookup or return arrays, just the value of the lookup cell.

IF in combination with VLOOKUP returns in #VALUE

I'm working with an Excel sheet that has 2 sheets.
Sheet 1 has all the data with the key in Column 1 and answer/data in Column 3.
There are a lot of rows and this is changing continuously, so one would make this maintenance free.
If a certain row in Sheet 1 has an empty value, sheet 2 will show a '0'.
To prevent this from happening, I created the following formula with example information.
Sheet 1 starts on A3 and ends on A300 (answers in column 3 aka C)
Record in sheet 1 with empty cell is A10
=IF(VLOOKUP(A10;'Sheet1'!$A$3:$C$300;3;TRUE);VLOOKUP(A10;'Sheet1'!$A$3:$C$300;3;TRUE);"")
So if value of A10 in Sheet 1 in Column 3 = TRUE, get that value and present it else show nothing.
This works flawlessly, however, when I update the cell in Sheet1 in C10, with Yes. The VLOOKUP in Sheet2 will return #VALUE.
Once I update the value in C10 with random numeric values such as 123456, Sheet2 will show 123456.
Once I remove the IF statement around VLOOKUP the value of Sheet2 will becomes Yes (after I updated Sheet1 C10 back to Yes).
Anyone know if IF(VLOOKUP) works on Text? In my situation it doesn't somehow, but with numbers its fine.
With kind regards,
Engineer
You need to change the logic a bit:
Check if A10 can be found on sheet 1 (can be done many different ways, I've chosen COUNTIFS).
If found, check that the VLOOKUP does not return 0.
=IF(COUNTIFS(Sheet1!A3:A300;A10)>0;IF(VLOOKUP(A10;Sheet1!A3:C300;3;TRUE)<>0;VLOOKUP(A10;Sheet1!A3:C300;3;TRUE);"");"")

Trying to find a product's weight from one table and show it agains that product on another table

I am blanking and getting frustrated so thought I would seek help.
In Excel, I would like to populate Sheet1 D2 with the correct weight.
To find it I would like to search Sheet 2 A:A for the code in Sheet1 A1 and return the value from the cell in the C:C from the match.
The result should mean Sheet 1 D2 = 6,334.72. A no match should return nil or 0.
I have tried Indexing with Match and I could not get a result other than NA or Value.
Sheet 1
Sheet 2
I assume you are talking about Sheet1 A2, not A1.
The formula at D2 is
=ifna(index('Sheet2'!$C:$C, match(A2,'Sheet2'!$A:$A,0)),0)
Also, please make sure the product codes on each worksheet are stored in the same format (numbers, perhaps). If one is number and another is text, you cannot get a match.

How to pair 2 columns together in Excel?

For example, One table is the formula, and the other is the data sheet.
For the formula, I want Column A to pair to Column B.
So, ZIPCODE1 in A1 equates to $6 in B1.
Like
12345 - $5
54312 - $4
12422 - $7
So, in the data sheet, whenever I type a zipcode, it will autofill/calculate with that dollar amount.
Sounds like you may be after a lookup formula.
You need to have a table like the above in your workbook, for reference. Let's say that this table is in Sheet2, from cell A1 to B4. Make row 1 the labels, ZipCode and Fee, so everybody can easily recognize what data the columns hold.
Let's further assume that in Sheet1 of your workbook you have a zip code in cell A1 and you want to see the respective price in cell B1. You now can use this formula in cell B1
=vlookup(A1,Sheet2!$A$1:$B$100,2,False)
In words: find the value from A1 (of the current sheet) in the first column of the table in Sheet2 that starts in A1 and goes to B100 (I'm using row 100 as an arbitrary last row of the table. There are more advanced ways to make the table reference dynamic). Return the value in the second column where column A has an exact match. For more info use the Excel help for Vlookup.
Another option is an Index/Match combo
=Index(Sheet2:$B:$B,match(A1,Sheet2!$A:$A,0))
In words: look at column B in sheet 2 and return the cell where column A in Sheet2 has an exact match for my value in A1 (in the current sheet).

If B2 in sheet 1 matches any cell on sheet 3, copy the next cell from sheet 3. (copying to sheet 1)

Anyone who could give me the excel formula for this? Thank you!
If B2 in sheet 1 matches any cell from column A of Sheet 3, copy the cell found on the right of that (column B).
Copying to a cell in sheet 1.
Thanks! (I hope this isn't too confusing.)
For example B2 is "8 December". Then there is a list of dates on Column A of Sheet 3. On column B of sheet 3 is a corresponding time. So for example, on the right of 8 December on Sheet 3 is 8:30, I want that to be copied on the cell I'm making a formula on.
Some folk use the LOOKUP function for this, but I like to use MATCH and INDEX because it gives you more freedom for more advanced formula (such as checking if there was a match or not) and has less requirements (such as data doesn't need to be sorted).
=INDEX(Sheet3!B:B, MATCH(Sheet1!B2, Sheet3!A:A, 0))
If you break it down into the parts, MATCH(Sheet1!B2, Sheet3!A:A, 0) returns the row number for the first matching cell in column A of sheet Sheet3. Then INDEX(Sheet3!B:B, ...) returns the value of the cell in column B of sheet Sheet3 at a specified row number.
If nothing matched, then you'll get a #NA error value.

Resources