Pergunta

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?

Foi útil?

Solução

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:

SO23231949 example

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.)

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top