Pick Out Email From a Row - excel

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.

Related

Search for duplicate text string in two columns and highlight, excel

I'm looking for a way to search and highlight duplicate text strings in two different columns in Excel; this means that the cell content doesn't have to be identical, instead of that is what I need is that if the content of column A is somehow contained in any cell of column B, both cells get highlighted.
For example, let's say that I have two columns, one named "Patient" and another one called "Couples". So, what I would need is to make a comparison between both columns, and if one of the patient's names is within a couple, both cells get highlighted:
Column A. Patient name | Column B. Couple name
John Smith | Adriana Lewis - Mark Rutte
Peter Brown | Giaccomo Down - Rosy Lawn
Jerry Goldsmith | Bob Loewe - Gigi Pink
Ewan Thompson | Sonia Farrel - John Smith
In this example, the content of A2 ("John Smith") is also contained in B5 ("Sonia Farrel - John Smith"), so that I would need that both A2 and B5 get highlighted. Also, both columns don`t have the same range, one is shorter than the other, since there are more names than couples; and it can happen that two names in different cell are contained in a single couple, so that all three cells should get highlighted.
I have tried everything, with no success... please help!
Multiple ways to do this but here's one option with conditional formatting.
Rule applied to data in column A, using COUNTIF and wildcards.
=COUNTIF($B$2:$B$5,"*"&A2&"*")>0
Rule applied to data in column B, using ISNUMBER, SEARCH and SUMPRODUCT.
=SUMPRODUCT(--ISNUMBER(SEARCH($A$2:$A$5,B2)))>0

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.

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

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

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.

excel delete row if column contains value from to-remove-list

Let's say that I've got a sheet - number one - with over 5000 rows (say, columns 'A' - 'H' each).
In another sheet - number two - I have a "to-remove-list" - a single column 'A' with 400 values, each containing alphanumerical string (example: xxx1234).
I have to remove every entire row from sheet number one, if column 'E' contains any value from "to-remove-list" (from column 'A' of sheet number two).
By removing the entire row, I mean delete the row and move it up (not leaving the blankspace)
How do I achieve that? Any help would be much appreciated.
Given sheet 2:
ColumnA
-------
apple
orange
You can flag the rows in sheet 1 where a value exists in sheet 2:
ColumnA ColumnB
------- --------------
pear =IF(ISERROR(VLOOKUP(A1,Sheet2!A:A,1,FALSE)),"Keep","Delete")
apple =IF(ISERROR(VLOOKUP(A2,Sheet2!A:A,1,FALSE)),"Keep","Delete")
cherry =IF(ISERROR(VLOOKUP(A3,Sheet2!A:A,1,FALSE)),"Keep","Delete")
orange =IF(ISERROR(VLOOKUP(A4,Sheet2!A:A,1,FALSE)),"Keep","Delete")
plum =IF(ISERROR(VLOOKUP(A5,Sheet2!A:A,1,FALSE)),"Keep","Delete")
The resulting data looks like this:
ColumnA ColumnB
------- --------------
pear Keep
apple Delete
cherry Keep
orange Delete
plum Keep
You can then easily filter or sort sheet 1 and delete the rows flagged with 'Delete'.
I've found a more reliable method (at least on Excel 2016 for Mac) is:
Assuming your long list is in column A, and the list of things to be removed from this is in column B, then paste this into all the rows of column C:
= IF(COUNTIF($B$2:$B$99999,A2)>0,"Delete","Keep")
Then just sort the list by column C to find what you have to delete.
Here is how I would do it if working with a large number of "to remove" values that would take a long time to manually remove.
-Put Original List in Column A
-Put To Remove list in Column B
-Select both columns, then "Conditional Formatting"
-Select "Hightlight Cells Rules" --> "Duplicate Values"
-The duplicates should be hightlighted in both columns
-Then select Column A and then "Sort & Filter" ---> "Custom Sort"
-In the dialog box that appears, select the middle option "Sort On" and pick "Cell Color"
-Then select the next option "Sort Order" and choose "No Cell Color" "On bottom"
-All the highlighted cells should be at the top of the list.
-Select all the highlighted cells by scrolling down the list, then click delete.
For a more modern answer, bring the data into powerquery, merge the 2nd sheet into the first with a left outer join. Expand. Use drop down filter to remove any rows that don't match as null. Remove test column and file close and load back to excel
New Answer 9/28/2022
Now you can use FILTER function that simplifies it.
=FILTER(A3:B7, ISNUMBER(MATCH(A3:A7,D3:D4,0)))
Note: The question requires to modify the original data sheet, this is in a general not recommended, because you are altering the input, better to have a working sheet with the transformations required.

Resources