Worksheet 1 contains a list of names and quantities that are updated daily below (i.e. AAA is a name and 1 is the quantity):
Name
look.AAA :1
look.BBB :2
look.CCC :3
I'm trying to get the table in Worksheet 2 to search for text within the column range and extract the quantities using formulas.
So far i've tried search, lookup, vlookup, find & match functions (and combinations of these) but everything produces errors. I've tried to see if someone else has done something similar but I could not find anything online:
=match(aaa,sheet1!A2:A4)
I'm expecting to retrieve the quantity number by searching for the name and finding it within the text of a cell range.
You are on the right track. There are several ways to do this. VLOOKUP, LOOKUP, and a combination INDEX/MATCH are some of the more common methods. Since you started with match, this solution will carry on with your methodology.
Match is going to tell you which row of the selected range you are looking for. What you need to do is return the value from the same row but in a difference column. For starters we just need to tweak you match formula. Since you are looking for a string (text), and are hard coding it, the text value should be in quotes. Your Match formula becomes:
MATCH("AAA",sheet1!A2:A4,0)
That zero at the end tells match you are looking for an exact match. The other possible values for 0 are 1 and -1, but you need to have a sorted list and they will do an approximate match going forward or in reverse respectively. For a reverse search the list needs to be sorted in reverse order.
Now that you have a formula for the correct row within the selected range, you can use that in an INDEX formula from a matching size range somewhere else in the workbook. In this case you have it in the adjacent column. Your ultimate formula becomes:
INDEX(Sheet1!B2:B4,MATCH("AAA",sheet1!A2:A4,0))
Alternative options
VLOOKUP
VLOOKUP("AAA",sheet1!A2:B4,2,0)
See below revised solution:
I have given a name "Look_Rng" to the list which contains the original data.
My logic is to use a combination of MID, LEN and FIND functions to extract a number range and a text range from the original range first:
Number Range: {=--MID(Look_Rng,FIND(":",Look_Rng)+1,LEN(Look_Rng)-FIND(":",Look_Rng))}
which will return {1;20;300;3;2}
Text Range: {=MID(Look_Rng,MIN(IFERROR(FIND(D2,Look_Rng),33000)),LEN(D2))}
which will return {"AA";"oo";"CC";"e.";"lo"}
Then use MATCH function to find the position of the given name in the Text Range. For instance, if you are looking for CC in the Text Range, it will return 3.
Lastly, use INDEX function to locate the value in the corresponding position in the Number Range. For instance, CC is in the 3rd place in the Text Range, so its corresponding position in the Number Range is 300.
The full formula is quite long, and you MUST press Ctrl+Shift+Enter when exiting the formula to make it work because it is an ARRAY FORMULA.
{=INDEX(--MID(Look_Rng,FIND(":",Look_Rng)+1,LEN(Look_Rng)-FIND(":",Look_Rng)),MATCH(D2,MID(Look_Rng,MIN(IFERROR(FIND(D2,Look_Rng),33000)),LEN(D2)),0))}
Let me know if you have further questions.
P.s. I agree with #ForwardEd that it would be much easier if you use a couple helper columns to break the original data down and use simple INDEX+MATCH or VLOOKUP to look for the value. My answer used the same logic anyway.
Related
I am trying to build an excel formula, that will reference another column based off of the first word. The first word does not need to have an exact match, it will however, need to find words that are “very similar” to each other. If the words, are not a close match, I would need the original cell to show in the results tab (as seen below). I would need the excel formula to do the following:
Column A......….Column B (with desired info)......….Column C (results)
Upper Body...……….Upper...………………......………………......……Upper
Upper Arms...…………….....………………......………………......…… Upper
Upper Legs...…………….....………………......………………......…… Upper
Lower Legs...…………….....………………......………………......…… Lower Legs
I have tried, the VLookup with the range lookup, as “True”, however the above example will be a lot more complex, with the real data set I am using. Any help would be greatly appreciated.
You can extract first word and then use Index() and Match().
You will first need to get the first word of column A. You can do this by splitting column A by a delimiter (split after first space) or by using a formula.
Formula example: =IF(ISERR(FIND(" ",A2)),"",LEFT(A2,FIND(" ",A2)-1)) where A2 is the cell you are looking at.
When you have that value you can then use =Index(Match()) to look up value. Match allows for fuzzy matching as long as you do not set the last parameter to 0.
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.
My problem explained in Excel
Column A1:A22 have some binary numbers (0, 1). As you can see I highlighted numbers with GREEN fill color that match my pattern I want to find.
Column C5:C22 have formula as you can see in formula box, that CONCATENATE first four numbers ( A1:A4, A2:A5 etc..) in data set and check if it matches my pattern.
If this first four numbers match my pattern, I want Excel to count all NEXT numbers that are right after this pattern.
The biggest problem is that I can't do this this way because I have data set that have approximately 30.000 binary records in it, and my RAM memory can't handle that much of CONCANTENATE formula to count all NEXT values, after my pattern occurs.
I want someone to help me find other way without making HELPER columns, I want Excel formula, that in steps:
Search for pattern in data set..
IF pattern in data set matches my desired pattern, make AVERAGE of all values right after pattern occurs. So in example above my AVERAGE in cells C5:C22 = 0,66
I hope that I explain this in details so you know my problem, I need formula to do all the math stuff, I can't use helper columns like in example above.
Thanks in advance.
Concatenate once then Substitute Pattern to find
You can use CONCATENATE function in one cell, getting all the 1's and 0's into one cell.
Then SUBSTITUTE the Pattern to find with empty string "".
Then count how many Patterns were "Substitued" (Matched).
Like so:
Formulas in cells
D5-Concat all: =CONCAT(A1:A22)
E5-Len all: =LEN(D5)
F5-Substitute: =SUBSTITUTE(D5;Pattern;"")
G5-Len after: =LEN(F5)
H5-Matches: =(E5-G5)/PatternLen
To get it into one cell:
=(LEN(CONCAT(A1:A22))-LEN(SUBSTITUTE(CONCAT(A1:A22);Pattern;"")))/PatternLen
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.
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)