Convert Table Columns to csv File (Stacking Columns and Turning Percentages into Numbers)

captainxcel

New Member
Joined
Jul 28, 2017
Messages
35
Office Version
  1. 2016
Platform
  1. Windows
Hello and thanks in advance for any help on this. I'd like to create a macro that takes my model portfolios and creates a file for uploading into rebalancing software and any guidance would be helpful. While I can record the sequence, I'd like some help creating a for loop across the column headings that takes the column contents and adds them to the vertically stacked csv file format. A small wrinkle is that the column headers need to be included, percentages need to be converted into numbers (i.e. 50% = 50) and descriptions need to be added from a key. In the sample spreadsheet below, the model portfolio table is at the left, the key in the middle, and the csv file format at the right. Thank you.

Table to Stacked Column Example.xlsx
ABCDEFGHIJKLM
1SymbolGRFIRAAGGRCodeDescriptioncsv data below
2SPY60.00%0.00%25.00%10.00%GRGrowth PortfolioModelDescriptionSymbolTarget Percent
3AGG10.00%50.00%0.00%0.00%FIFixed-Income PortfolioGRGrowth PortfolioSPY60
4GLD0.00%0.00%50.00%0.00%RAReal Assets PortfolioGRGrowth PortfolioAGG10
5AAPL3.25%0.00%0.00%20.00%AGGRAggressive PortfolioGRGrowth PortfolioGLD0
6MSFT6.75%0.00%0.00%20.00%GRGrowth PortfolioAAPL3.25
7MINT10.00%25.00%0.00%0.00%GRGrowth PortfolioMSFT6.75
8QQQ10.00%0.00%0.00%50.00%GRGrowth PortfolioMINT10
9TIP0.00%25.00%25.00%0.00%GRGrowth PortfolioQQQ10
10Total100%100%100%100%GRGrowth PortfolioTIP0
11FIFixed-Income PortfolioSPY0
12FIFixed-Income PortfolioAGG50
13FIFixed-Income PortfolioGLD0
14FIFixed-Income PortfolioAAPL0
15FIFixed-Income PortfolioMSFT0
16FIFixed-Income PortfolioMINT25
17FIFixed-Income PortfolioQQQ0
18FIFixed-Income PortfolioTIP25
19RAReal Assets PortfolioSPY25
20RAReal Assets PortfolioAGG0
21RAReal Assets PortfolioGLD50
22RAReal Assets PortfolioAAPL0
23RAReal Assets PortfolioMSFT0
24RAReal Assets PortfolioMINT0
25RAReal Assets PortfolioQQQ0
26RAReal Assets PortfolioTIP25
27AGGRAggressive PortfolioSPY10
28AGGRAggressive PortfolioAGG0
29AGGRAggressive PortfolioGLD0
30AGGRAggressive PortfolioAAPL20
31AGGRAggressive PortfolioMSFT20
32AGGRAggressive PortfolioMINT0
33AGGRAggressive PortfolioQQQ50
34AGGRAggressive PortfolioTIP0
Models
Cell Formulas
RangeFormula
B10B10=SUBTOTAL(109,[GR])
C10C10=SUBTOTAL(109,[FI])
D10D10=SUBTOTAL(109,[RA])
E10E10=SUBTOTAL(109,[AGGR])
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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