Excel: Look up for the text contains - excel

I need to do a lookup and return the value based on if the text contains it.
Please see my excel sheet below, What I need is a formula, which will help my 'Category' column to be filled 'Category' column of the look up table.
Note: Kindly see my excel sheet in below link.
I tried the formula '=VLOOKUP(B2,A13:B16,2,TRUE)' but it is not giving the expected result.

This is a slight twist on the normal "find this string inside a list of others". It requires an array formula that searches for matches using FIND.
Picture of ranges
Formula in cell A2 is an array formula (entered with CTRL + SHIFT + ENTER) and is copied down for each item. It searches in the list of lookup for an item that is included in item and returns the result from category associated with lookup.
=INDEX($E$2:$E$4,MIN(IF(IFERROR(FIND($D$2:$D$4,B2)>0,FALSE),ROW($D$2:$D$4)))-ROW($E$1))
How it works
INDEX is returning from category and needs a row number to return
The row number is determined by using FIND which will check if a string is included in part of another string. In this case, the string to search for is the lookup table and we are matching within the item.
FIND will return #VALUE! if no match is found, this is converted to FALSE with IFERROR because #VALUE! will no work with MIN later.
The IF will then return the ROW number or FALSE for the match that was found.
MIN is used to convert the list of ROW numbers to the smallest number. This means that multiple matches are not handled.
This ROW number is then used as the return for the INDEX. There is an offset applied here -ROW(E1) which allows for the data tables to start in a row other 1:1.

Related

How to reverse Match for cell containing string Excel 2010

From column O I would like to lookup column A, starting from my current row, to find the first cell with a comma. Goal is to have the correct date in each row.
Table I'm working in https://i.imgur.com/BByfjzy.png
=MATCH("*"&","&"*",$A$1:INDIRECT("A" & ROW()),0)
If I could just run it backwards that be great but I'm not finding a way that works with wildcards or contains in excel 2010. My other thought was to make an a range based off position, invert it, find the index and do length - index but I'm not sure how I would go about that. I'm pretty new to excel so any help would be apricated.
=MAX(IF(ISNUMBER(FIND(",",A1:INDEX(A:A,ROW()))),ROW(A1:INDEX(A:A,ROW())),))
Instead of MATCH which looks from top to bottom and returns the first match, use MAX to return the max row number of the cell containing ,. You can use either FIND or SEARCH.
If you wrap it in INDEX you get your value:
=INDEX(A:A,MAX(IF(ISNUMBER(FIND(",",A1:INDEX(A:A,ROW()))),ROW(A1:INDEX(A:A,ROW())),)))
It might require to be entered with ctrl+shift+enter. I'm unable to test it in older Excel version.
Edit for further explanation of how it works:
A1:INDEX(A:A,ROW()) is to be read as cell A1 up to the current row in column A. So if you're at row # 10 it would equal A1:A10.
Wrapping that range in FIND returns the position of the character you try to find.
If given character is not found in the cell it returns error #N/A.
So if you have row 1 and 9 containing , in this case, it returns an array of numbers for the hits and errors for the non-hits, for instance {2,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,#N/A,6,#N/A}
Wrapping that in ISNUMBER changes the non errors to TRUE and the errors to FALSE.
IF takes that array and in case of TRUE (a number) it returns the row number (same indexed range is used).
Then MAX returns the largest row number of that array.
Instead of FIND you could also use SEARCH. FIND is case sensitive, and SEARCH isn't, further on they operate the same).

Excel VBA/Formula to find a cell that includes search term?

I was not sure how to really create the question...
But the problem I am having is this: I have a list (in rows) that relate to a regulatory document, and after trying to create some sort of for loop or elaborate VLookUp/Index formula, I'm requesting help.
For example:
Now I want to use the rows to find the corresponding section in the document. I've already extracted and formatted the compliance document so it is in excel format.
So what I really need is this: a formula or VBA script that can
1. take the compliance number (for example 1A-1 which exist in Cell A3) and go find a cell (in single column D) that has JUST 1A-1, not 1A-1.1, not 1A-1.1.2, etc. and return it to the adjacent cell to 1A-1, for example.
Many thanks ahead of time... I am so lost!! :/
VLOOKUP vs INDEX/MATCH
You can do the 'lookup' two ways (that I'm aware of):
Using VLOOKUP:
The B3 cell contains your formula
=IF(ISERROR(VLOOKUP(A3,C:D,2,FALSE)),"",VLOOKUP(A3,C:D,2,FALSE))
where 'FALSE' is indicating there has to be an exact match and the data doesn't have to be sorted.
Using INDEX with MATCH:
The F3 cell contains the Index/Match formula
=IF(ISERROR(MATCH(A3,C:C,0)),"",INDEX(D:D,MATCH(A3,C:C,0)))
where '0' is indicating there has to be an exact match and the data doesn't have to be sorted.
INDEX/MATCH preferable!?
The MATCH function finds the position (row number if whole column is used) of the found match. This way (there's another) of using the INDEX function uses exactly this found match to return a cell's value in that position (row) in ANY specified column range (column). So they are the ideal combination.
With the VLOOKUP function you have to additionally specify the column index (range_lookup) of a range which could get complicated when the columns aren't adjacent as in this case. Most importantly, the function doesn't work if the lookup data is to the right of the match data.
VLOOKUP NOT WORKING! INDEX/MATCH STILL WORKING!
try this formula
The formula in cells
B2: =INDEX(E:E,MATCH(A2,F:F,0))
C2: =INDEX(G:G,MATCH(A2,F:F,0))
MATCH(A2,F:F,0) is finding Cell A2 in column F (0 means it will find
exact match) and will return the first row number when it would find that
INDEX(E:E,MATCH(A2,F:F,0)) will return contents of column E where row number is returned by the Match formula

IF Values match return true

I am trying to get some code working but when I change a target cell into a range of cells I get an error #VALUE!
this code works
=IF(AND(A1=Sheet2!A2,B1=Sheet2!B2),"TRUE","FALSE")
but if I add a range I get #VALUE! Error
=IF(AND(A1=Sheet2!A2:A10,B1=Sheet2!B2:B10),"TRUE","FALSE")
Update : Here is an example of what I am trying to achieve
Any help would be much appreciated
Many Thanks,
And
Different approach from your logic statement. Instead it looks through your table and match the name with the row and the column with the date selected and the pulls the value at that location.
=INDEX($B$7:$G$8,MATCH($B3,$A$7:$A$8,0),MATCH(C$1,$B$6:$G$6,0))
IMPORTANT: The names in you B3:B4 area have to be unique and spelled identical to your A7:A8 area. That included trailing or leading spaces that you may accidentally drop in.
Adjust reference ranges to match your need if tables are on different sheets of your workbook.
THIS IS AN ARRAY FORMULA - Hit Ctrl+Shift+Enter While still in the formula bar
=INDEX(B2:B10,SMALL(IF(A2:A10=A1,IF(B2:B10="ONCALL",ROW(A2:A10)-1)),1))
=INDEX(B2:B10, - Look through B2:B10 and return the row number calulcaulated by:
SMALL(IF(A2:A10=A1,
IF(B2:B10="ONCALL",
ROW(A2:A10)-1)),1))
This is building an array of row numbers minus 1 where both IF statements are true (Date matches and "ONCALL" present), SMALL then returns the nth value in ascending order - I have asked for the 1st match (or the smallest row number) which INDEX then uses to return the result.

Index match match - correct approach?

I have a data source in the format as the one below. In reality, that would contain few thousand rows.
I need to use something like INDEX-MATCH-MATCH in order to be able to get the "Status" for each "Content" item for each UserID.
The final result should look like this. The first two columns are not dynamic.
The INDEX formula goes to C and D.
I am using the following sequence to try and write the formula, but I don't seem to understand where the problem is.
=INDEX(Sheet1!A:K, [Vertical Position], [Horizontal Position])
look up the user with ID xxx:
=INDEX(Sheet1!A:K, MATCH(A2, Sheet1!A:K,0), [Horizontal Position])
look up the status for eLearn1.
=INDEX(Sheet1!A:K, MATCH(A2, Sheet1!A:K,0), MATCH("Status", Sheet1!A:K,0))
What am I doing wrong?
The question is not clear, but I think you are trying to do a LOOKUP based on the values of two columns. So for a particular value of Column A (UserID) and Column B (Content) you need to return Column H (Status).
This can be done using an array formula to return the row number of the matching line which can be fed into INDEX. Note, that this will only work as long as Columns A&B only have unique pairings.
I have set up some sample data:
Columns A-C are my source data. Cells G2:H4 are the lookup.
The formula is:
=INDEX($C$1:$C$7, SUM(($A$1:$A$7=$F2)* ($B$1:$B$7=G$1)*ROW($C$1:$C$7)))
This needs to be entered as an array formula by pressing CTRL-ALT-ENTER.
The formula works by matching the value you are searching for in both arrays and multiplying out the results. This should give you a result array consisting of all False with one True indicating the matched row. This is then multiplied against the row number to return the correct row to the INDEX formula.

vlookup on array with variable number of rows

I'm trying to use the approximate match function of vlookup to find a value in an array, that can be of different length. I just dragged the lookup array as far down as possible in order to assure that all data is selected, however, the approximate match option will then always select the last value in the array. Is there a way of feeding vlookup the correct lookup array in order to extract the correct value? Regards
Create a dynamic range name and feed that into the Vlookup. For example, if your lookup table starts in A1 and has numeric data, define a name called TheRange with the formula
=Sheet1!$A$1:Index(Sheet1!$D:$D,match(99^99,Sheet1!$A:$A,1))
This will return a range from A1 to column D down to the last row with a number in column A. When rows are added or removed from the table, the named range will be recalculated automatically and adjust to the new dimensions.
Then can use
=vlookup(YourValue,TheRange,2,1)
Adjust cell addresses to your situation. I take it you are aware that for an approximate match the data must be sorted ascending for the formula to return the correct result. With the 1 or TRUE as the last parameter, the formula will always return a result, but if the table is not sorted on the first column, the result is most likely not correct.

Resources