Rearranging Data in a Table

rwmill9716

Active Member
Joined
May 20, 2006
Messages
493
Office Version
  1. 2013
Platform
  1. Windows
I have stock trading results in Columns AX through BD (hundreds of rows). I need formula for Columns BE through BI that will let me rearrange the data as shown. Essentially, I'm taking data that's presented as 1 row per symbol and converting it to 2 rows per symbol then rearranging the data as shown into those two rows: the 1/2 position trade results (date and profit) are moved to single columns.

Thanks for your help,

Ric


Excel 2010
AXAYAZBABBBCBDBEBFBGBHBI
20SymbolDate PurchasedPriceDate 1st half soldProfitDate 2nd half soldProfitSymbolDate PurchasedPriceDate 1/2 Position SoldProfit
21CC01/05/17$20.821/10/20172.251/10/2017$2.45CC1/5/2017$20.821/10/2017$2.25
22THO01/12/17$100.291/13/2017$2.501/19/2016$2.001/10/2017$2.45
23SF01/12/17$48.691/13/2017$3.001/13/2017$3.00THO1/12/2017$100.291/13/2017$2.50
24PAA01/19/17$30.531/24/2017$1.751/25/2017$1.501/19/2017$2.00
25WDC01/19/17$72.011/20/2017$1.251/20/2017$1.25SF1/12/2017$48.691/13/2017$3.00
26SCHN01/25/17$23.801/31/2017$0.552/1/2017$0.551/13/2017$3.00
2016 (2)
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Just copy Symbol column into new sheet, make a space between each symbol using macro and then copy it back to col BE and then use vlookup formula to fetch the rest of the columns for that symbol.

I have stock trading results in Columns AX through BD (hundreds of rows). I need formula for Columns BE through BI that will let me rearrange the data as shown. Essentially, I'm taking data that's presented as 1 row per symbol and converting it to 2 rows per symbol then rearranging the data as shown into those two rows: the 1/2 position trade results (date and profit) are moved to single columns.

Thanks for your help,

Ric

Excel 2010
AXAYAZBABBBCBDBEBFBGBHBI
CC
THO
SF

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]20[/TD]
[TD="bgcolor: #D9D9D9, align: center"]Symbol[/TD]
[TD="bgcolor: #D9D9D9, align: center"]Date Purchased[/TD]
[TD="bgcolor: #D9D9D9, align: center"]Price[/TD]
[TD="bgcolor: #D9D9D9, align: center"]Date 1st half sold[/TD]
[TD="bgcolor: #D9D9D9, align: center"]Profit[/TD]
[TD="bgcolor: #D9D9D9, align: center"]Date 2nd half sold[/TD]
[TD="bgcolor: #D9D9D9, align: center"]Profit[/TD]
[TD="bgcolor: #D9D9D9, align: center"]Symbol[/TD]
[TD="bgcolor: #D9D9D9, align: center"]Date Purchased[/TD]
[TD="bgcolor: #D9D9D9, align: center"]Price[/TD]
[TD="bgcolor: #D9D9D9, align: center"]Date 1/2 Position Sold[/TD]
[TD="bgcolor: #D9D9D9, align: center"]Profit[/TD]

[TD="align: center"]21[/TD]
[TD="bgcolor: #C0C0C0"]CC[/TD]
[TD="bgcolor: #C0C0C0"] 01/05/17[/TD]
[TD="bgcolor: #C0C0C0, align: right"]$20.82 [/TD]
[TD="bgcolor: #C0C0C0, align: right"]1/10/2017[/TD]
[TD="align: right"]2.25[/TD]
[TD="align: right"]1/10/2017[/TD]
[TD="align: right"]$2.45 [/TD]

[TD="align: right"]1/5/2017[/TD]
[TD="align: right"]$20.82 [/TD]
[TD="align: right"]1/10/2017[/TD]
[TD="align: right"]$2.25 [/TD]

[TD="align: center"]22[/TD]
[TD="bgcolor: #C0C0C0"]THO[/TD]
[TD="bgcolor: #C0C0C0"] 01/12/17[/TD]
[TD="bgcolor: #C0C0C0, align: right"]$100.29 [/TD]
[TD="bgcolor: #C0C0C0, align: right"]1/13/2017[/TD]
[TD="align: right"]$2.50 [/TD]
[TD="align: right"]1/19/2016[/TD]
[TD="align: right"]$2.00 [/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]1/10/2017[/TD]
[TD="align: right"]$2.45 [/TD]

[TD="align: center"]23[/TD]
[TD="bgcolor: #C0C0C0"]SF[/TD]
[TD="bgcolor: #C0C0C0"] 01/12/17[/TD]
[TD="bgcolor: #C0C0C0, align: right"]$48.69 [/TD]
[TD="bgcolor: #C0C0C0, align: right"]1/13/2017[/TD]
[TD="align: right"]$3.00 [/TD]
[TD="align: right"]1/13/2017[/TD]
[TD="align: right"]$3.00 [/TD]

[TD="align: right"]1/12/2017[/TD]
[TD="align: right"]$100.29 [/TD]
[TD="align: right"]1/13/2017[/TD]
[TD="align: right"]$2.50 [/TD]

[TD="align: center"]24[/TD]
[TD="bgcolor: #C0C0C0"]PAA[/TD]
[TD="bgcolor: #C0C0C0"] 01/19/17[/TD]
[TD="bgcolor: #C0C0C0, align: right"]$30.53 [/TD]
[TD="bgcolor: #C0C0C0, align: right"]1/24/2017[/TD]
[TD="align: right"]$1.75 [/TD]
[TD="align: right"]1/25/2017[/TD]
[TD="align: right"]$1.50 [/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]1/19/2017[/TD]
[TD="align: right"]$2.00 [/TD]

[TD="align: center"]25[/TD]
[TD="bgcolor: #C0C0C0"]WDC[/TD]
[TD="bgcolor: #C0C0C0"] 01/19/17[/TD]
[TD="bgcolor: #C0C0C0, align: right"]$72.01 [/TD]
[TD="bgcolor: #C0C0C0, align: right"]1/20/2017[/TD]
[TD="align: right"]$1.25 [/TD]
[TD="align: right"]1/20/2017[/TD]
[TD="align: right"]$1.25 [/TD]

[TD="align: right"]1/12/2017[/TD]
[TD="align: right"]$48.69 [/TD]
[TD="align: right"]1/13/2017[/TD]
[TD="align: right"]$3.00 [/TD]

[TD="align: center"]26[/TD]
[TD="bgcolor: #C0C0C0"]SCHN[/TD]
[TD="bgcolor: #C0C0C0"] 01/25/17[/TD]
[TD="bgcolor: #C0C0C0, align: right"]$23.80 [/TD]
[TD="bgcolor: #C0C0C0, align: right"]1/31/2017[/TD]
[TD="align: right"]$0.55 [/TD]
[TD="align: right"]2/1/2017[/TD]
[TD="align: right"]$0.55 [/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]1/13/2017[/TD]
[TD="align: right"]$3.00 [/TD]

</tbody>
2016 (2)
 
Upvote 0
Thanks, Sunny,

What would the macro look like that would loop through 1000 of these rows? I like the Vlookup approach. Since the same symbol will occur multiple times, I will have to confine each vlookup formula to two rows and copy it down the list.

Ric
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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