I have a list of alphanumeric inventory items in Column A. They are sorted ascending by value.
In Column B, I have an unsorted list of the inventory items filenames.
I'd like to place a formula in Column C that finds the cell in Column B that contains a substring that matches Column A.
I've experimented with several forms of VLOOKUP and INDEX/MATCH, but the best I've gotten is an index number of the matching cell. That isn't quite what I need, but its the closest I've gotten.
I'd really like to get the entire value of the cell in Column B.
I know of one way to do this, and one additional resource that might make your life much easier.
First, If I had the index of the matching cell, I would simply use an indirect function. They're used like this:
indirect("string reference to a cell")
In your case, cell C1 would contain
=indirect("A" & B1)
Second, the resource I have in mind is something I read long, long ago, but stuck in my mind as absolutely brilliant. It uses the lookup function, which only exists for backwards compatibility but has turned out to have hidden utility. See this MrExcel.com page for more info. Barry Houdini's answer is, to prevent link rot, repeated here without the question itself: =LOOKUP(2^15,SEARCH(D$2:D$10,A2),E$2:E$10)
Related
Looking for something like a typical index match formula that can look to the right and return value to the left, but look at all columns in a range. Take below valid formula for example.
(Excel 2021.)
Finds A1's value in column D, and it returns value from column C.
=INDEX($C$1:$C$10,MATCH(A1,$D$1:$D$10,0))
In my ideal world I can Keep $D$1 and change $D$10 to $F$10 so it searches all columns D/E/F, and still returns C like below. However that does not work in our real world, any other ideas please? Thanks!
=INDEX($C$1:$C$10,MATCH(A1,$D$1:$F$10,0))
Update*
To clarify there are mix of letters and numbers. Also this table will be about 50k rows so hoping as simple as possible.
Also Column C will all be unique for sure, and D-F should be unique values but there is a chance a mistake and a few duplicates might be in.
You need MMUL() with INDEX(). Try below formula if you have Excel-365.
=FILTER(C1:C10,MMULT(--(D1:F10=A1),SEQUENCE(COLUMNS(D1:F1))))
For older version try
=INDEX($C$1:$C$10,LARGE(MMULT(--($D$1:$F$10=A1),TRANSPOSE({1,1,1}))*ROW($C$1:$C$10),1))
Since your INDEX/MATCH take from the same rows, you can first simplify your original search with
=XLOOKUP(A1,$D$1:$D$10,$C$1:$C$10)
XLOOKUP combines HLOOKUP and VLOOKUP with exact match being the default.
This will work for searching three rows
IFERROR(IFERROR(XLOOKUP(A1,$D$1:$D$10,$C$1:$C$10), XLOOKUP(A1,$E$1:$E$10,$C$1:$C$10)), XLOOKUP(A1,$F$1:$F$10,$C$1:$C$10))
We can name the columns colC, colD, colE, and colF and it becomes
IFERROR(IFERROR(XLOOKUP(A1,colD,colC), XLOOKUP(A1,colE,colC)), XLOOKUP(A1,colF,colC))
As with other lookups, this returns the first value or #N/A error.
This could be made more scalable for higher number of rows if we are allowed to add a column somewhere.
I am not familiar enough with excel to build this formula:
I am trying to write an excel formula to search for matching data in columns A and F, then report a value from column B that corresponds to the same row as the "found" A column into column G.
So basically, I'm putting the formula into G607 and I am searching, in column A for a value that matches F607.
If I find a matching value in A104, I want the value that reports in G607 to be B104.
My spreadsheet does not have any duplicate values in column A.
VLOOKUP is cool, but I would warn you away from it before you get comfortable with it. VLOOKUP is silly because:
It requires you to define an array where the unique IDs are ALWAYS the left column.
It requires you to COUNT COLUMNS LIKE A HEATHEN to tell it what the output is.
There are memory and other structural problems not worth going into.
You have to sort Column A if you care about exact matches. Amateur hour here.
Guys, I'm joking, I don't care that much, but seriously, Index/Match is cooler.
In G607, put this:
=INDEX(Sheet1!B:B,MATCH(Sheet1!F607,Sheet1!A:A,0))
Break it down:
INDEX() helps us by saying, "What is the answer you want? Cool, now tell me the row and column?" Obviously, if we knew the row/column, we wouldn't care.
Que the MATCH() Equation - this is where we say, "Hey, see F607? Yeah, find where it matches in Column A."
IF THERE WERE DUPLICATES IN COLUMN A, it would stop at the first entry and report that. Not a concern here since you don't have duplicates!
The 3rd argument (has a 0) in the MATCH equation just says "Hey, make it an exact match".
Index/Match like this makes sure that we can:
Pick any match column we want. VLOOKUP wouldn't work if Column B had the Unique IDs, and Column A was the answer instead.
Pick any output column we want without counting. Seriously, who counts in 2018?
Arrays are minimized b/c 1 and 2 above, plus other reasons.
No sorting required. Winner. Winner.
Assuming all cells are on the same sheet,
G607 = VLOOKUP(F607, A:B, 2, 0)
I have a long column in an Excel spreadsheet that I'd like to match with another long column in the same sheet.
The columns look like:
And I want to make a script that will allow me to check A to F using B to copy and paste F,G,H to B,C,D if A and F match to look like:
The problem is that A and F don't usually match exactly; only most of the words - as you can see with "metal corp & company" vs "metal corp".
Is there any way I can do this via script? I know I can see if they match exactly using something like =NOT(ISERROR(MATCH(A2,$F$2:$F$5, 0))) etc....Or to explicitly state the name in quotations, but nothing to match only part of the entry to another.
Also, is there any way to automatically paste F,G,H if the match is found?
Ok, you can do a vlookup and break the formula with copy/paste values if needed. you may not need to do that.
So, you need to consider how to make vlookup work. vlookup can take a value and search for it in an array and return a corresponding value in that row of the array that it is found. given your ask for the following values along the right, this should work well if we can get a value to be matched. afterwards just repeat the same formula with +1 to each column being returned (F, G, H).
So, your issue is getting the match to work since you think most of the time the values do not match 100%, but are close. you need to make them match, somehow. either by manually assigning an lookup table where the alias's are aligned. e.g. on another sheet, in column A, have "metal corp & company" and in column b, have "metal corp" or by a formula to establish a match. depending on the number of rows, doing it manually may be substantially less work than a formula. a formula can work it the alias's are consistently wrong in a certain fashion. if it is random, then a formula won't work.
I would try something as simple =vlookup(value,array,column,TRUE). the true value will return an approximate match instead of exact match.
See example screenshot, the only formula is in column B. "hi" is close enough to "high" and then "there" is returned from column e.
This pictures shows my table and formula's yield
I have used following formula to extract result from a table.
Its working perfectly fine but I am hoping to level up my understanding of Excel formulas.
The trouble is that I use IF in Excel way to often.
what I wanted to know is if its possible to use a different approach, something that can work similar to if but is perhaps more sophisticated.
=IF(OR(J2="08L",J2="08R"),IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$34,0)),"LAM",IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$35:$E$35,0)),"West",IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$36:$G$36,0)),"East",IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$37,0)),"SFD",NA())))),0)
I very much appreciate any help.
Now that there is an example, I think this is a good question. You've recognised that your formula is fairly messy and also can't be easily expanded if there are more routes.
The problem is that Excel is very good for searching for a value in a single row or column, but not as good for searching for a value in a block of data.
You can simplify this problem by creating an additional column that has each entire route in a single cell. You can do this just by concatenating values. In your example, use column H:
=B2&" "&C2&" "&D2&" "&E2&" "&F2&" "&G2
This will create a string with the entire route in a single cell. Spaces are added in between each part of the route to make sure you don't accidentally create a sequences of letters that matches part of another route. It doesn't matter if there are blank cells, there will just be some extra spaces at the end which doesn't matter. Fill this down the column to get the entire path for each route in a single cell.
Then, you can create a formula that tries to find the 3 letters anywhere in any of the full routes.
=INDEX($A$2:$A$5,MATCH("*"&left(I2,3)&"*",$H$2:$H$5,0))
This formula is basically a deconstructed vlookup. It determines where the 3 characters can be found in column H, then gives back the corresponding value from column A.
The MATCH function tries to find the left 3 characters of I2 in column H. The MATCH function normally tries to find a complete exact match (with the last parameter being equal to 0), but we can just add wildcards to the search value. The MATCH function then returns the index of the range where it was found. I.e., if it was found in the 2nd cell of the range H2:H5, it returns the number 2.
The INDEX function then just gets a value from a range based on an index. In this case, it will get the 2nd value from range A2:A5.
I need to find a way to search for a value in a named range and to return the column next to that range. The reason is simple: I do use list validation with a named range in column A. In this list there are complete name of product types (ex. Relay, Contactor, Enclosure) and I need to return a short description from column B (ex. Rly, Cont, Encl) so that when the user searches the list it's easy to find what he is looking for. I know I could extend my range to $A:$B but if I do then all the values of $B will be included in the list...
This shows a way to figure out what I need: =VLOOKUP(A1;"RANGE+1C",2,0)
I tried so many ways with offset and index but couldn't find a way to do so... I even thought it would be possible of doing it with relative reference (ex. =VLOOKUP(A1,Description;1"RC[1]",0) or something like that...
Also looked in Google to find some info but it seems to be something very unfamiliar...
I need to do this in a formula and not in VBA.
Here is the link to an example file:
http://www.filedropper.com/descriptionbuilder
Any hint?
Thank you!
What you probably want instead of VLOOKUP is the MATCH & INDEX combo.
MATCH is a function which tells you the row number where a duplicate value is found from your selected list - it's like half of VLOOKUP. INDEX is a function which pulls a value out of a list, based on its position # that you give it - it's like the other half of VLOOKUP.
I see your one Range in column A with your ID data is Description - I'll assume that column B has no 'named' range that aligns with yours. I'll assume that column B has other data, and that column A starts somewhere after row one [specifically, I'll assume it starts at row 5]. Together the formula would look like this:
=INDEX(B:B,ROW(A5)-1+MATCH(A1,Description,0))
This says: find the row # within Description that matches the text in A1. Then add the row # of A5 - 1 (this then alignts the top of Description with the top of column B). Then pull that value from column B.
Alternative Method using VLOOKUP and OFFSET
Another method would be to first define how many rows are in Description, and then using that information and the OFFSET function, create a new area which essentially represents Description but going across column A & B instead of just column A. This would look as follows (again, assuming Description starts at A5):
=VLOOKUP(A1,OFFSET(A5,0,0,ROWS(Description),2),2,0)
This says: count how many rows are in Description. Build an array with OFFSET which starts at A5, with as many rows as there are in Description, and 2 columns. (So with 3 items in Description, this would be A5:B7). Then use that new Range in VLOOKUP, and try to find A1 the Description area in column A, and return the result from that row in column B.
You can use Offset to expand a named range by one column and then feed it into Vlookup Something like:
=VLOOKUP(C1,OFFSET(RANGE,0,0,,1+COLUMNS(RANGE)),1+COLUMNS(RANGE))
To test is, I created a named range (called "RANGE") in Column A, I placed values in Column B adjacent to the named range, put a lookup value in C1 and the entered the above formula. It succeeds in retrieving the desired value.
On edit: I think that Grade'Eh'Bacon's answer is excellent and is probably the best approach to this specific problem, but it strikes me as potentially useful to know how to expand the reference of a named range without changing the name itself, so I am keeping this answer.