I have an Excel table with two columns and about 500 rows. In the first column is the name of a company, and in the second column is a list of partners, delimited by a semicolon. For example, one row would look like [Apple][Foxcomm; Samsung; Microsoft; Intel]. There is an unknown number of partners for each partners cell, and some partners appear with multiple companies.
What I'm trying to accomplish is to reorganize this collection of data into a new table, where each column header is a partner (unique, doesn't repeat), and each company that shares that partner is listed below.
So far I've manged to find a formula for splitting the text based on the delimiter semicolon, but it spreads it across the row (predictably). I've also found formulas for transcribing a table by basically switching the rows and columns, but I'm not sure if I'll even need to do so. My main problem seems to be finding the correct way to phrase my searches on Google!
How can I get Excel to do what I'm trying to accomplish? Or, what would be a better way to display this information?
I fear you may be doing more work than really necessary. I think you have most of the components and as I am not sure quite where something is awry an image may help:
Then, assuming Apple is in A2,
=IFERROR(IF(SEARCH(C$1,$B2)>0,C$1,),"")
in C2 copied across to the right (I think as far as GF2) then all these formulae copied down to suit.
Better to TRIM before removing duplicates (switch order of 3. and 4.)
If elegance and re usability is not important, I would suggest that you, for the sake of this example, imagine your starting sheet is called 'sheet foo':
Use a delimited text to columns(they're separated by semicolon)
Then you would need to use the =LEFT and =MID functions to trim the
brackets and semicolons.
Then copy paste values.
Right click 'sheet foo', go to copy\move, and create a copy, we'll
call this 'Sheet bar'
Convert all of the data in 'Sheet bar' to a table (this step is not
absolutely necessary, but it will help me explain) and name the table
'Table bar'
Return to 'Sheet foo'
Then use the remove duplicates tool on each column
Then copy and paste each column on to the end of the following column
until you've got one very long column. (so you would copy lets say
B2:B500, and paste it at C501, then copy C2:C1000 paste it on to
D501, etc. It's okay if they're not all equal number of rows, as
there may have been different occurrences of duplicate data)
Re-apply the remove duplicates tool, and you should have a column
with all of the unique values for partners in 'Sheet foo'
Copy, paste and transpose (ALT - E - S - E - Enter, in order, not at
once) on the same row as your headers
You would now have every possible partner as a column header, in
'Sheet foo'
Delete all of the columns in 'Sheet foo' that contain each company's
partners; this would leave your column structure so your headers are
| company | first partner | second partner | third partner | ... | final partner |
then under each company header do a
=COUNTIF(FirstRowOfTableBar, CompanyHeader)
and anchor 'FirstRowOfTableBar' on the X axis 'CompanyHeader' on the
Y axis. So it would look something like
=COUNTIF('Sheet bar'!$B2:$B10, 'Sheet foo'!B$2)
Then copy and paste this formula for all company's rows, and all
partner's headers.
Now you have a 0 where a company\partner relationship does NOT exist,
and a 1 where a company\partner relationship DOES exist.
Notes:
This could all go terribly wrong if the company column changes order somehow, in which case an even uglier solution involving either index\match, or offset, or perhaps array '=IF' formulas might be needed.
Related
I'm fairly new to coding and i've been googling around for the last few hours trying to solve this problem but it seems to be a little beyond what i'm able to do so i would be very grateful for some help
In Sheet1, I have a table which has columns between M - CV (175 columbs). For each column, i have an "ID number" value in row 3. From Row 6 to the end of the table, i have several "search terms" separated by commas in the column CV
In Sheet2, the corresponding "ID Numbers" are in column B. Column AN contains strings.
For each ID Number value in sheet1, i'm looking to find find all the corresponding cells in sheet2 where the ID number in Column B is the same, and Column AN of sheet2 contains at least one of the "search terms" in column CV
For each ID number, i'm hoping to join the entries in Column AN of sheet2 which match the criteria above and paste them into Row 5 of the respective column in Sheet1
I've gone around in quite a few circles trying to do this and i'm back to square 1 with no code to show for it.
I've tried to research both the autofilter function, and using for loops. The research i've done indicates that for loops are rather slow to run for a large data set.
I'm hoping to find a solution which is as easy to read and understand as possible
I hope i've given enough information for everyone to understand and help
THank you in advance
My Excel subscription has expired an I've started using Google Sheets for most of my spreadsheet work, so I tested this there. Some conversion may be required. I did this using formulas, not VBA also, not sure if that changes things for you.
If I understand correctly, you have two sheets with a shared key column, sheet 1 contains search terms across multiple columns, and sheet 2 contains search terms comma delimited in a single column.
With this setup we want to bring the search term column of sheet 2 into the correct row of sheet 1 by key using VLOOKUP. I made a named range in sheets which contained all my data on sheet 2 and called it "dst". My formula was then =VLOOKUP(A2, dst, 7, true) since my key in sheet 1 was in column A, dst was the range I was searching, my column with my delimited search terms was column 7 in relation to dst, and I had ordered sheet 2 by key. I pasted this formula relatively down all rows as needed.
We want to construct a regex string using our search terms across multiple columns in sheet 1, into a single cell. I used =JOIN("|", B2:E2) on sheet 1 since my search terms were in columns B:E, and this resulted in a regex that looked like this for me: alligator|dog|rabbit|lizard where alligator, dog, rabbit, and lizard, were all search terms in that row. Paste down relative as needed.
We want to run our regex against our search target cell containing the comma delimited search terms. I ran =REGEXMATCH(F2, G2) where F2 was my delimited search terms from sheet 2, and G2 was my constructed regex for the row. Paste down relative as needed.
A screenshot of my completed sheet 1:
Once you know which cells have matches you can do whatever you want.
When the all three columns "Last Name, First Name and DOB" match on any rows between the 2 sheets, I need to have the account numbers from the matching rows listed on a third sheet. There are thousands of rows in each sheet. There will likely be multiple matches for some accounts. I prefer to put the functions on the 3rd sheet so that I can change out the lists in the first 2 sheets without needing to update them.
Sheet1
Acct # Last Name First Name DOB
89158 Stevens John 1/23/2012
Sheet2
Acct # Last Name First Name DOB
124578 Stevens John 1/23/2012
Sheet3
Sheet1 Acct # Sheet2 Acct#
89158 124578
Thank you in advance!
This works with duplicate values
The formula will need to be entered as an array (once copy and pasted while still in the formula bar hit CTRL+SHIFT+ENTER) and the range adjusted to fit your total values.
=IFERROR(INDEX(Sheet1!$A$2:$D$50,MATCH(1,($C2=Sheet1!$B$2:$B$50)*($D2=Sheet1!$C$2:$C$50)*($E2=Sheet1!$D$2:$D$50),0),1),"No match found")
The exact same formula can be used again changing Sheet1! to Sheet2!.
This will search for the last name that is in Sheet3!C2, first name that is in Sheet3!D2 and the DOB that is in Sheet3!E2.
I have only locked off the column in case you are looking to use this for a large volume of data and wish to drag it down.
If you want to display the additional account numbers that meet the search criteria and are only using sheet 3 to search for one person, then you will need to look at using INDEX(), MATCH() and SMALL().
I had looked to include this alternative in my answer too but I am now leaving the office. It won't take me long to conjure if you struggle so drop me a comment and I will be happy to explain how it all works.
EDIT: To list all ID's found for the search criteria - Leave blanks where not found
=IFERROR(INDEX(Sheet1!$A$2:$D$50,SMALL(IF(COUNTIF($C$2,Sheet1!$B$2:$B$50)*COUNTIF($D$2,Sheet1!$C$2:$C$50)*COUNTIF($E$2,Sheet1!$D$2:$D$50),ROW(Sheet1!$A$2:$D$50)-MIN(ROW(Sheet1!$A$2:$D$50))+1),ROW(Sheet1!1:1)),1),"")
Again, replace sheet 1 for sheet 2 and update the ranges to match what you are searching through, use CTRL+SHIFT+ENTER in the formula bar to make the formula an array then you can drag it down to cover all the potential matches, best to aim for what you believe would be the highest number of duplicate IDs.
Let me know how you get on, if this answers your question, please mark this as an answer using the tick to the left, thank you.
I ended up putting list A and List B into a sheet and then using this formula: =ISNA(MATCH(B2&C2&D2,I:I&J:J&K:K,0)) Then I created another sheet where I added list B and then list A and used the same formula. Once the calculation was complete for each sheet, I used filters to only list the matches for the first lists in each spreadsheet.
I then took the matches for each sheet and listed them side by side in the third sheet. I made sure the sort was matched between the two lists and then was able to scroll through a page at a time and identify a few users with multiple account numbers in each system.
It's not as automated as I would like, but it is done for now. Thank you Stack Overflow!
I have two excel files, one that I pulled from excel and the other that I pulled from SAP. One file, the larger one, has a column named EmployeeID and the other has a column named EMP_ID, the only difference is the name, the actual employee id within these columns is the same. What I am wanting to do it combine these two files to make a single file; however, for example, Employee ID 'ZZZ' on the first excel file may be on line 1, but on the other file the EMP_ID of 'ZZZ' may be on line 35.
Is there a way to somehow combine these 2 files? Also, sorting by EMP_ID A to Z won't help, because the files don't have the exact same number of entries, so that wouldn't sync them so that each employee is on the same line on each file.
These two files are for reference if it matters. File 1 - http://i.imgur.com/go1S6Ra.png File 2 - http://i.imgur.com/x4vOKIN.png
Here's a pure excel solution. Open file 1 one and go to an empty sheet. Copy and paste the content of file 2.
Go to the first cell in a blank column on sheet two and use vlookup. The formula will look something like this, but you'll have to modify it.
=VLOOKUP(A1,Sheet1.$A$1:$B$419,2,FALSE)
There are four arguments and you will need to play with the first three to get what you want.
A1 Change this to the cell where the employee ID lives in sheet two. So if it's in the third column, this should be C1
Sheet1.$A$1:$B$250 This is where the data from file 1 is. The default name for the first tab is Sheet1 but it might be something different depending on how you opened the file. The second part is the data range. Top left cell and bottom right cell. So if you have 5 columns in sheet one and 1000 rows it will be $A$1:$E$1000 (I'll explain the dollar signs at the end)
1 The third argument how many columns the target data is to the right of the employee ID. So if your columns are ID, First Name, Last Name, putting 3 here would get you the last name.
FALSE, this controls excel's matching behaviour. TRUE looks for close matches, but really it just makes thing unpredictable.
Once the search is working and you're looking up what you want, fill the formula in for the rest of the column. You will get an error if the ID you're trying to lookup isn't in Sheet1, so make sure you tweak the formula on one that exists. If you need to look up multiple things (e.g. First Name and Last Name), just drag the formula to the right and put in a different number for the third argument.
So what's the deal with the dollar signs? This affects what happens when you drag the formula down or over into new cells. If you write this:
=VLOOKUP(A1,Sheet1.A1:B100,2,FALSE)
and drag it down one cell you'll get this:
=VLOOKUP(A2,Sheet1.A2:B101,2,FALSE)
All the row coordinates go up by one. If you dragged it over instead, all of the column coordinates would go up by one, like this:
=VLOOKUP(B1,Sheet1.B1:C100,2,FALSE)
Dollar signs freeze them in place, so the range doesn't drift. You want the search value to keep moving because every line should be looking up the next employee ID, but you don't want the range to move.
Im trying to create a list of values in 'sheet 3 column A', that are created by listing all values that are duplicates in two other sheets.
The duplicates are to be found by looking through each value in 'sheet 1 column P' and checking if that value also exists in
'sheet 2 column A'
I've tried reading up on this and there seem to be a number of functions I can use and not sure if I should use.
You need to use the VLOOKUP function, combined with IF. Together they are very very powerful. I really suggest you read up on them.
The following formula in Sheet 3, Column A (starting at row 2) will do what you want:
=IF(ISNA(VLOOKUP(Sheet1!P2,Sheet2!$A$2:$A$99,1,FALSE)),"",Sheet1!P2)
Copy that formula down from A2. I've assumed you have headings in row A. If you have more than 98 rows of emails (values to check), change $A$99 to be something like $A$9999.
So, let me get this straight. You have two workbook tabs. You want to get the intersection of the set (figure out where they are overlapping, duplicate, however you want to say it).
I would do one of two things, depending on how much you like Excel and moving your data around.
Option 1: Create a PivotTable of the data (assumes no duplicates within lists, only between lists)
Copy the data from the second list after the end of the first list (so both lists are now one list)
Insert a Pivot Table (on the ribbon), choosing your single column for the source
PivotTable options will pop up. Put the email address field in RowLabels and Count in the Summarize Values box.
Click on the count column of the pivot and sort largest to smallest.
All your duplicates will have Count > 1
Option 2 - use CountIf
This does not involve moving your data.
Go to sheet 2. In the next column over (from your info, it would be Column Q), put the CountIf function:
=CountIf(Sheet1!A:A,P2)
Then you can sort descending on your new count column to find duplicates.
CountIf performs very well in Excel if your lists are very large.
This can be refined slightly using iferror giving:
=IFERROR(VLOOKUP(Sheet1!P2,Sheet2!$A$2:$A$99,1,False),"",Sheet1!P2)
but is essentially the same thing
I have two columns, the first column will have the name of a object, the second is who it belongs to. I want a new sheet for each person to list what they had assigned to them. here is a example:
dog F
cat F
bell S
whistle
bird F
So Fred has a dog, cat, and a bird; Scott has a bell; and no one has a whistle on their page. Now doing a simple IF() i can get it to look like this for Fred's page
TOP OF ROW
dog
cat
bird
And Scott's page will look like
TOP OF ROW
bell
however I want Fred's to look like
TOP OF ROW
dog
cat
bird
and Scott to be the same.
My current train of thought is to use =VLOOKUP($C$1,Items!A2:C1000,3) in a hidden column in D to tell me which row my data is in, (where Column C on Items is a hidden column with the row number of the row and C1 is the search parameter (S or F)), then =IFERROR(CELL("contents",INDIRECT(ADDRESS($D2,2,1,TRUE,"Items"))),"") , however I other than changing my row index of my search array to 1+ the last found item (which i have not figured out how to do) I can not figure out how to continue searching for the next item.
I know C++ and C# but never have coded in VBA before and I rely heavily on the MSDN and to my knowelge there is no MSDN section dedicated to the Excel API.
One way of achieving the list that you are looking for without any VBA code is to make use of the advanced filter.
On sheet 1 the input list is entered as follows
on sheet2 enter the filter criteria (this criteria means contains F in Owned by column)
and finally on sheet3, call the advanced filter function like this
make sure to select copy to another location
select the sheet1 input list as the list range
select the sheet2 filter criteria as the criteria range
and select somewhere in sheet3 as the output range (the copy to entry)
If you prefer to go down the route of excel VBA programming a good first step is to try out the macro recorder in excel (tools - macros - record macro)
good luck!
There is a good way of doing this with functions in excel.
Essentially you need to create a running countif
So in C2 you would have =COUNTIF($B$2:$B2,"F") Obviously the "F" could also be a reference to another cell. If you fill this formula down the range it will expand the range. Eg. in C3 it will say =COUNTIF($B$2:$B3,"F")
This will give you a running total in column C in your example this would mean:
dog F 1
cat F 2
bell S 2
whistle 2
bird F 3
The fact that you have 3 2s doesn't matter because a vlookup will always match to the first match it finds.
This technique has a lot of different applications. And depending on the data you may find it easier to put this on the left of the data so the VLOOKUP will be easier.