Vlookup search in a comma separated field - excel

Excel worksheet with 2 columns.
Cell A1 has values like 111,222-225,333 then cell A2 almost same format data like 010,011,444-499.
How can we lookup a value, say 333 and output corresponding value on adjacent column --(in column B or C etc)?
Vlookup doesn't seem to be a good choice as the first column value needs to be unique.
Secondly, how could we tackle the same above scenario if the lookup value is in that range (say 224, which is in the range of 222-225)

I am not sure what value you want to have, but if you want to have the whole cell u might use:
=LEFT(A1;FIND("333";A1)+3)
in B1 and simply fill it to the rest of column B.

You could share a worksheet with Googledocs with data people could share.
But in essence you would be doing something like string manipulation on A1, to extract the 333.
a1=111,222-225, 333
b1=VALUE(RIGHT(TRIM(A1),3))
c1==VLOOKUP(B1,E1:F2,2,FALSE) // a
d1==IF(ISNA(C1),"",C1) // a
e1=333 e2=a
f1=444 f2=b
The // a - represents the calculated content of the cell

Related

Can i use a variable instead of a row number in Excel

I want to create something similar to a PivotTable where if you type in a cell let's say F1 a value like "5", and another cell that uses that value as a variable let's say F2. F2=A(F1) for example and that should be equal to F2=A5. Is that possible or something similar.
The point of this is to easily fetch data from a row. So if all the data of 1 entity is stored in row 3 and columns A,B,C,D i can easily use that data where i need it by changing the value of a single cell
Example:
Column A is Name, B is Last Name, C is Address, D is City. You have 50 rows of data and another sheet for printing that data. Sheet 2 A1 is used to change a variable so that if i type "3" the cell A2 will show the data from Sheet1A3, A2 will show the data from Sheet1B3 and so on.
In F2:
=INDEX(Sheet1!A:A,A2)
would achieve that.

dynamically select an excel element

guys,
I want to select an element from a column based on column name. This column changes its place time to time and that's why I want to achieve this dynamically. I couldn't post an image here so I'll try my best to explain it in words.
In the excel sheet I'm trying to select an element located at B2 dynamically based on column name of B2. For sake of simplicity lets say the column name of B is column2. Since my column2 would not always be on B place I want to select that dynamically.I also want this to achieve without VBA code if possible.
Really look forward for your help. Thanks!
Below formula may help you in this,
Explanation:
MATCH will return the column position of "DOB", if DOB is in column C, MATCH will be returning 3.
ADDRESS will the row 1 address of column C, $C$1 hence; which is a text in fact.
Pass this text to INDIRECT function so that it gets converted to range. Now INDIRECT function will be pointing to cell C1.
Use cell C1 as reference and return 3 item in that colum.
=OFFSET(INDIRECT(ADDRESS(1,MATCH("DOB",1:1,0))),3,0)
Formula is expecting row 1:1 as header. You can pass B2 in place of "DOB".

Excel - Find a value in an array and return the contents of the corresponding column

I am trying to find a value within an array and then return the value in a specific row in the corresponding column.
In the example below, I need to know which bay the Chevrolet is in:
Column A Column C Column D Column E
Chevrolet Bay 1 Bay 2 Bay 3
Toyota Ford Saturn
Honda Chevrolet Jaguar
Ferrari Subaru Lexus
Mitsubishi Hundai BMW
I am looking for Chevrolet in the array C2:E5. Once it determines that the Chevrolet is in Column D, I need for it to return the value in D1. If it was in column E, I need it to return the value in E1.
Any help would be greatly appreciated. Thank you so much in advance.
Try this Array Formula:
=INDEX($C$1:$E$5,1,SMALL(IF(NOT(ISERROR(SEARCH(A1,$C$1:$E$5))),COLUMN($A:$C),99^99),1))
or if you are sure that each column contains exactly what's being searched it can be written like this:
=INDEX($C$1:$E$5,1,SMALL(IF($C$1:$E$5=A1,COLUMN($A:$C),99^99),1))
Enter formula in any cell by pressing Ctrl+Shitf+Enter.
How does it work?
Our ultimate goal is to find the Column that contains the match:
First we did the search for the match using this formula: SEARCH(A1,$C$1:$E$5). It just checks if any of the entries matched A1. Actually, it can be simplified to $C$1:$E$5=A1 but I'm not sure if all entries in each column match exactly what's in A1.
That formula will produce an array of values when entered as array formula. Something like: {SEARCH(A1,C1), SEARCH(A1,D1), SEARCH(A1,E1);... SEARCH(A1,E5)}. The result will be array of number(s) and error (if non was found). But we don't want that, else we will be returning error everytime.
We then use IF(NOT(ISERROR(SEARCH(A1,$C$1:$E$5))),COLUMN($A:$C),99^99). This formula returns the Column Number if there is a match and a relatively huge number 99^99 otherwise. Result would be: {99^99, 99^99, 99^99, 2, ..., 99^99}.
And we are close to what we need since we already have an array of Column and huge number. We just use SMALL to return the smallest number which in my opinion is the lowest Column Number where a match is found. So SMALL(IF(NOT(ISERROR(SEARCH(A1,$C$1:$E$5))),COLUMN($A:$C),99^99),1) would return 2. Which is the column where Chevrolet is referenced at $C$1:$E$1.
Since we already have the column number we simply use INDEX Function which is: INDEX($C$1:$E$5,1,2).
Note: 99^99 can be any relatively large number. Not necessarily 99^99. Actual 16385(max column number in Excel 2007 and up + 1) can be used.
Result:
Another quick and dirty answer is to put a "dummy" row above the entire data set and then determine which placeholder column returned the correct result.
In B1, you can put the equation
=MATCH($A$2,B3:B6,0)
And then in C1, you can put
=MATCH($A$2,C3:C6,0)
And so on until you've covered all the rows and columns. Change the B3:B6 & C3:C6 to reflect the actual rows of data in the given column.
Now, the fun array formula which will actually return the bay. I have this array formula in cell A1 and it is looking from B1:D1, but you can move cell A1 anywhere you want and the B1:D1 range should be all the dummy columns you made above. Also, this is assuming that the bays you want are in row 2 (if they are in a different row, change R2C to R#C where # is the row number). In order to properly enter, enter the formula and then press CTRL+SHIFT+ENTER.
=INDIRECT("R2C"&SUM(IF(ISERROR(B1:D1),FALSE,B1:D1))+1,FALSE)
If the formula is entered properly, it will show curly brackets { } around the equation when you single click on the cell.
This formula will do it, assuming that the lookup value is in A1:
="Bay "&SUMPRODUCT((B2:D5=A1)*(COLUMN(B2:D5)))-1
You could easily adjust it to add more rows and columns.
The formula returns the column number that contains the lookup value and concatenates it with the word Bay to return the exact result you want.
The -1 at the end adjusts for the fact that the Bay 2 column is actually the third column in the worksheet, so you might need to adjust that offset as well.
The SUMPRODUCT function is much undervalued. More on it here:
http://fiveminutelessons.com/learn-microsoft-excel/multiply-two-columns-and-add-results-using-sumproduct
The SUMPRODUCT formula above is perfect for what I want.
E.g. to find the location - COLUMN and ROW - of a given value at A1 in a 2D Range A2:J44
use: =SUMPRODUCT((A2:J44=A!)*(COLUMN(A2:J44))) gives the Absolute* COL#
and : =SUMPRODUCT((A2:J44=A1)*(ROW(A2:J44))) gives the Absolute* ROW#
(not where it is in the range)
These can then be used in e.g. INDEX() or CELL() etc functions.

extracting of specific values in a cell

I'm trying to extract specific values from a specific cell where Column A is the input and Column B is the output.
Column A Column B
AB,CD,EF,GH,IJ,KL ABCDEFGH
AB,CD,MN,EF,OP,UV ABCDEF
QR,AB,ST,CD,GH,WX ABCDGH
The formula i am using in Column B is:
=CONCATENATE(MID(A2,(SEARCH("A",A2,1)),2),MID(B2,(SEARCH("CD",B2,1)),2),MID(B2,(SEARCH("EF",B2,1)),2),MID(B2,(SEARCH("GH",B2,1)),2))
However if i am to drag down the formula until the last row, it will return a #VALUE! since some of the values in the SEARCH formula did not appear Column A.
So what I need is a generic formula that will only extract the values AB,CD,EF,GH OR whatever value is available in Column A just like in my example.
Best Regards,
I would condition on whether or not something exists, and print it accordingly:
Column B's formula uses an approach that matches
IF(ISERROR(FIND(<string>,<within_string>)),"",<string>)
and concatenates these using &. ISERROR avoids error outputs, while also helping to place content (an empty string "" in this case).

EXCEL: Need to find a value in a range of cells from another worksheet and return value from adjacent cell

I am trying to find the formula that will search in column A (of worksheet "ABC") to find a value matching G4 in worksheet "XYZ" Once that value is found, return the value of the cell adjacent (column B of "ABC") to the cell in which this formula exists in worksheet "XYZ". All sheets are in the same workbook.
Thank you so much!
here's an example of what you're describing:
In spreadsheet ABC, you have a reference value in column A and data in column B
In spreadsheet XYZ, you have a matching number in column A. You'd like to pair the data from spreadsheet ABC to the value in XYZ:
If you notice the formula in the formula bar on the second picture, you'll see the vlookup formula to pull the data for this example. I also added an apostrophe in front of the formula in cell B1 (image 2) to have it display the formula. Note the formulas are slightly different since they point to different reference cells.
Also, here's a great reference for how the vlookup function works:
http://chandoo.org/wp/2012/03/30/comprehensive-guide-excel-vlookup/
Here is another solution that's closer to your adjusted question.
This solution still uses the vlookup formula. Instead of using it to associate a value on multiple rows, you can look-up a single value. (same function, different application)
Again, I'll point you to a great reference for how the vlookup function works:
http://chandoo.org/wp/2012/03/30/comprehensive-guide-excel-vlookup/

Resources