Need to Pull Data from Second Sheet using Part of Cell on First Sheet - excel

I am manipulating data created by another program and saved into Excel, and that data is NOT consistent in the way that some things are abbreviated, nor on the spacing in some of the cells. This site has helped a lot with pulling out some of the data, but this one has me stumped. If it's already been answered, please point me to that answer, as I couldn't find it. :)
I have a "reference" worksheet (that stays hidden) where the first column is possible abbreviations, and the second column is the value that needs to be returned. The reference sheet might show: (cells seperated by //, rows separated by \: Apple//Apple\ Apple//Apple\ Banana//Banana\ Ban//Banana\ Org//Orange\ Orange//Orange)
The created/imported data might include 4 cells that look like this (cells separated by //: 1234 - Apple - Cut and serve //Sometimes 836 Banana Raw//Org Peel // 730-Orange-Juice):
I need to pull out the name of the fruit referenced in each. Effectively, what I need is the row (on the reference sheet) where the contents of the cell in the first column are included in the data imported. Then, I can use a lookup to pull the value from the cell in the second column of that row.
So, in my sample data, the formula would return:
2
3
5
6
I hope that is clearly explained. Oh, and I can only use formulas, no programming of any sort.
Thanks for any direction you can give.

In my opinion there is no way for do this with a formula if you import the data as you show because you can't do a "search" for each "substring" (or word) contained in a cell comparing it with a list of other substrings.
Otherwise if you import the data of the "created/imported" sheet specifyng as cell-separator the space " " and as row separator the "//" you will have a single word for each cell, like
A | B | C | D | E | F | G |
1234 - apple - cut and serve
sometimes 836 banana raw
org peel
730 orange juice
here you can use the VLOOKUP for every cell of the columns formed with the import for search the word in the "reference" sheet, so use the same amount of cols (in this case 7) and for each cell of the cols do the VLOOKUP for the corresponding cell (A to G in the example) and find your friut, with something like this
=VLOOKUP(A1;'[Worksheet_reference.xlsx]sheet_reference'!$A$1:$A$100;2;FALSE)
you can obtain something like
AA | AB | AC | AD | AE | AF | AG |
N/A N/A apple N/A N/A N/A N/A
N/A N/A banana N/A
orange N/A
N/A orange N/A
you can add an IF with an ISNA for detect the N/A values and write something else instead of them, for example
=IF(ISNA(VLOOKUP(A1;'[Worksheet_reference.xlsx]sheet_reference'!$A$1:$A$100;2;FALSE));"";VLOOKUP(A1;'[Worksheet_reference.xlsx]sheet_reference'!$A$1:$A$100;2;FALSE))
for return "" instead of N/A, and then you can concatenate the results (you said there is only one friut for each row) all the rows for have the result in one single row, like in cell AF
=AA&AB&AC&AD&AE&AF&AE
you will obtain only the friuts...
This is not so "clean", but it's the only way i can imagine ;)
Ettore

Related

Extracting all information(different) with same row name form a excel worksheet using formula

I have a excel workheet having a table with multiple rows having same name with different information in the corresponding columns. Now using a formula I want to extract this infomation into a new table? SOLUTION HAS TO BE USING AN EXCEL FOMULA ? NO FILTERS NO PIVOT TABLE OR VBA
I have tried vlookup. to search for multiple values. I dont want information from a single column but rather from all the columns. There could be thousands of columns with same and different values.
I have tried this formula : =INDEX(Worksheet!A2:AK350;KKLEINSTE(WENN((A5=Worksheet!A2:A350);VERGLEICH(ZEILE(Worksheet!A2:A350);ZEILE(Worksheet!A2:A350));"");1))
The table looks like this for example:
Place People Salary Status
japan | resident_1 | 564 | un-married
Delhi | resident_1 | 655 | un-married
china | resident_1 | 564 | un-married
japan | resident_2 | 748 | un-married
Now I want to extract a sub table from the above, like all the
infomation having PLACE name as "japan"
the reult should be this for each place in a different table:
japan | resident_1 | 564 | un-married
japan | resident_2 | 748 | un-married
Seems like a job for advanced filter, but you've already stipulated "no filters". If you're able to add two helper columns in your main table, maybe you can use the approach below.
This is my main_table worksheet (note the columns outlined in red, which have been added).
The formula in column E (starting from cell E2) is: =CONCAT(A2,"|",B2,"|",C2,"|",D2)
The formula in column F (starting from cell F2) is: =ROW()-ROW($F$2)+1
Drag/fill these formulas down to the last row in your main table.
This is my sub_table worksheet (note the cells outlined in green at the top, where you will eventually specify filter criteria).
The formula in column A (starting from cell A5) is: =ROW()-ROW($A$5)+1
The formula in column B (starting from cell B5) is: =IFERROR(SMALL(IF(ISNUMBER(SEARCH($B$2,main_table!$E$2:$E$10)),main_table!$F$2:$F$10,""),$A5),"")
The formula in columns C, D, E, F (starting from cell C5) is: =IF(ISNUMBER($B5),INDEX(main_table!$A$2:$D$10,$B5,COLUMNS($C5:C5)),"")
The formula in cell B2 is: =CONCAT(IF(ISBLANK($C$2),"*",$C$2),"|",IF(ISBLANK($D$2),"*",$D$2),"|",IF(ISBLANK($E$2),"*",$E$2),"|",IF(ISBLANK($F$2),"*",$F$2))
You should drag the formula down for the same number of rows that are in your main table.
I think newer/upcoming versions of Excel have a JOIN worksheet function which is more convenient/flexible than my usage of CONCAT above (so maybe use that if it's available to you).
Leaving the filter criteria blank should give you all rows. If you want partial matches, include wildcards in your input e.g. jap* or resident_*. If any of the values in your main table contain a |, you may want to use a different delimiter in the CONCAT formulas (otherwise you may get unexpected results/behaviour).
Once you're done, maybe you can use it like shown below:
See if this approach is any good for you (you will probably need to translate the formulas to your locale/region).

Excel highlight duplicates in 2 columns, ignoring same row

I have 2 non adjacent text columns that I wish to compare. There may be duplicates in both columns but if they are not on the same row I need them to be highlighted in both columns. In the example below, Barry and Larry would both be highlighted in Columns A & C.
| Col A. | Col B. | Col C.
Row1.| Harry | London | Harry
Row2.| Barry | Paris | Larry
Row3.| Larry | New York | Barry
Row4.| Gary | Munich | Tom
If the same names are not aligned in the same row I would then cut and paste the offenders to resolve the problem. In this case the Barry in column C would be cut and inserted into row 2, forcing Larry down into row 3. Nothing would then be highlighted.
I guess it is a conditional formatting problem but I can't get a formula to work. I would appreciate some ideas.
So if I am understanding you correctly, you want to:
1) Find duplicates and highlight them
2) Move the offenders
Is there some reason this needs to be two parts? For moving the offenders I would run 2 loops, one to loop through the cells in column A, for each cell in column A I would loop through column C until I find the match, cut it, and paste it into the range that is two columns over from the current cell you are comparing in the first loop. you can use a range offset to find the right place to paste the name in column C.
Arrays would do this more quickly, so if you have a large number of records it would be worth looking in to.
You can use a dictionary object to accomplish both steps more easily, you can use dict.exists(value) to determine if a match exists and use those addresses for formatting, a quick google will help you with how to use them.
Honestly this seems like a homework problems so that's as far as I will go.

Excel multi column lookup

I am unsure how to Google this one. I have a table that looks like the below
Last Name | First Name | Team A | Team B | Team C
Smith | John | X | |
Doe | Jane | | X |
This would be the main sheet. The names in this sheet are divided into other sheet depending on what department they are in. Those sheets are setup in the same formats with the same columns. If the people in the main sheet are marked with an X in one of the columns I would like that same column marked in marked in the department sheets.
Your best bet might be to create a hidden column A where the value is a combination of column B and column C on all of your tabs. You could then use the standard VLOOKUP wrapped in an IFERROR clause.
For example,
=IFERROR(VLOOKUP(A1,Sheet1!A:F,3,False),"")
The IFERROR handles the instance that you may have a name on a sub tab not on the main tab. It returns blank instead of #N/A. The VLOOKUP is checking the value in A1 to what is in A1 on your main tab. A1 would be the combination of First and Last. The VLOOKUP would need to be in each of your team columns shifting the column returned number in each VLOOKUP.

Pick Out Email From a Row

I have over 100k rows similar to:
Joe | 123 | email#domain.com
Bob | 456
Ben | 567 | Denver | email#email.com
The emails could be at any point/cell in that row and some cells have # in them.
How could I get the following output:
Joe | email#domain.com
Bob |
Ben | email#email.com
or maybe just tag the email address onto the end of the row and then hide the other columns?
I've tried various bits and pieces but am getting nowhere fast.
Now that I know you can have it in every column, Add a column left of column A. In your example you then have B1="Joe", etc.
Then put this formula in A1:
=IFERROR(OFFSET(A1,0,SUM(IFERROR(IF(FIND("#",$B1:$O1)>0,1,0),0)*COLUMN($B1:$O1))-1),"")
Adjust the range $B1:$O1 to match your needs. I suggest you make it as tight as possible because array formulas are resource-intensive.
========================
If the email addresses were always in the last column of a given row, and if there weren't any blanks in the row until the last value, you could just do that:
First, Add a column left of column A. In your example you then have B1="Joe", etc.
Then, put this formula in cell A1
=OFFSET(A1,0,COUNTA($B1:$XFD1))
and drag and drop it on all your rows. (I'm using Excel 2010, hence XFD in the above formula. Adjust as you see fit, just make sure you use a range that covers the maximum number of columns for your dataset)
A bit of fun really.
Embolden the names and for the rest Replace All # without formatting with # and Font style Bold. Copy into Word, Select All, Find what: * with Font Not Bold, Use wildcards and replace with nothing. Copy back into Excel and Go To Special, Blanks. Right click on one of selection and Deleteā€¦, Shift cells left.

Add cell string to another cell if 2 cells are the same for 2 rows

I'm trying to make a macro that will go through a spreadsheet, and based on the first and last name being the same for 2 rows, add the contents of an ethnicity column to the first row.
eg.
FirstN|LastN |Ethnicity |ID |
Sally |Smith |Caucasian |55555 |
Sally |Smith |Native American | |
Sally |Smith |Black/African American | |
(after the macro runs)
Sally |Smith |Caucasian/Native American/Black/African American|55555 |
Any suggestions on how to do this? I read several different methods for VBA but have gotten confused as to what way would work to create this macro.
EDIT
There may be more than 2 rows that need to be combined, and the lower row(s) need to be deleted or removed some how.
If you can use a formula, then you can do those:
Couple of assumptions I'm making:
Sally is in cell A2 (there are headers in row 1).
No person has more than 2 ethnicities.
Now, for the steps:
Put a filter and sort by name and surname. This provides for any person having their names separated. (i.e. if there is a 'Sally Smith' at the top, there are no more 'Sally Smith' somewhere down in the sheet after different people).
In column D, put the formula =if(and(A2=A3,B2=B3),C2&"/"&C3,"")
Extend the filter to column D and filter out all the blanks.
That is does is it sees whether the names cells A2 and A3 are equal (names are the same), and whether the cells B2 and B3 are equal (surnames are the same).
If both are true, it's the same person, so we concatenate (using & is another way to concatenate besides using concatenate()) the two ethnicities.
Otherwise, if either the name, or username, or both are different, leave as blank.
To delete the redundant rows altogether, copy/paste values on column D, filter on the blank cells in column D and delete. Sort afterwards.
EDIT: As per edit of question:
The new steps:
Put a filter and sort by name and surname. (already explained above)
In column E, put the formula =IF(AND(A1=A2,B1=B2),E1&"/"&C2,C2) (I changed the formula to adapt to the new method)
In column F, put the formula =if(and(A1=A2,B1=B2),F1+1,1)
In column G, put the formula =if(F3<F2,1,0)
In column H, put the formula =if(and(D2="",A1=A2,B1=B2),H1,D2) (this takes the ID wherever it goes).
Put the formulae as from row 2. What step 3 does is putting an incremental number for the people with same name.
What step 4 does is checking for when the column F goes back to 1. This will identify your 'final rows to be kept'.
Here's my output from those formulae:
The green rows are what you keep (notice that there is 1 in column G that allows you to quickly spot them), and the columns A, B, C, E and H are the columns you keep in the final sheet. Don't forget to copy/paste values once you are done with the formulae and before deleting rows!
If first Sally is in A1 then =IF(AND(A1=A2,B1=B2),C1&"/"&C2,"")copied down as appropriate might suit. Assumes where not the same a blank ("") is preferred to repetition of the C value.

Resources