Reorder rows content for each row

siofont

New Member
Joined
Sep 23, 2015
Messages
2
Hi there,
First of all, I'm sorry because I don't know if I can explain this in a understandable way (I don't know how to search for it). And maybe is not posible.

I'll have a file with electoral results with this structure (simplified):

Code:
Place 1 name | Voters | Blank votes | 1st party | votes for 1st party | %vote for 1st party | 2nd party | votes for 2nd party | %vote for 2nd party | 3rd party | votes for 3rd party | %vote for 3rd party | etc (8 parties in total)Place 2 name | Voters | Blank votes | 1st party | votes for 1st party | %vote for 1st party | 2nd party | votes for 2nd party | %vote for 2nd party | 3rd party | votes for 3rd party | %vote for 3rd party | etc (8 parties in total; around 1000 places)

Example with PartyA, PartyB, PartyC:

Code:
Place1 | 100 | 0 | PartyA | 50 | 50% | PartyC | 30 | 30% | PartyB | 20 | 20% | etc
Place2 | 100 | 0 | PartyC | 80 | 80% | PartyB | 20 | 20% | PartyA | 0 | 0% | etc

The problem is that parties are ordered in each row from most voted to less voted. So the order of parties change in each row according to the amount of votes.
The ideal output format for me is this, where each column has data for the same party:

Code:
Place 1 name | Voters | Blank votes | partyA | votes for partyA | %vote for partyA | partyB | votes for partyB | %vote for partyB | etc
Place 2 name | Voters | Blank votes | partyA | votes for partyA | %vote for partyA | partyB | votes for partyB | %vote for partyB | etc

After that, I'll do some calculations and comparisons with Excel.

Is this posible?
Thank you!
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
very possible. here is how I did it using INDEX and MATCH. The purple highlighted cells need to be manually copied as a pair to the right for as many parties that you have. But once you get the first row completed you can copy that whole row downwards for as many places as you need. I put the raw data directly above the sorted data but you could rearrange them as needed to make room.


Excel 2010
ABCDEFGHIJKLM
1Raw data
2Place11000PartyA5050%PartyC3030%PartyB2020%etc
3Place21000PartyC8080%PartyB2020%PartyA00%etc
4
5
6Votes%Votes%Votes%
7PlaceVotersBlanksPartyAPartyAPartyBPartyBPartyCPartyC
8Place11000500.5200.2300.3
9Place2100000200.2800.8
Sheet1
Cell Formulas
RangeFormula
A8=A2
B8=B2
C8=C2
D8=INDEX($A2:$M2,1,MATCH(D$7,$A2:$M2,0)+1)
E8=INDEX($A2:$M2,1,MATCH(E$7,$A2:$M2,0)+2)
 
Upvote 0
Thank you very much, tybaltlives
Very quick, precise and useful answer. Put in my Excel, it works perfectly.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,206
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top