captainxcel
New Member
- Joined
- Jul 28, 2017
- Messages
- 35
- Office Version
- 2016
- Platform
- 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 | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | |||
1 | Symbol | GR | FI | RA | AGGR | Code | Description | csv data below | |||||||
2 | SPY | 60.00% | 0.00% | 25.00% | 10.00% | GR | Growth Portfolio | Model | Description | Symbol | Target Percent | ||||
3 | AGG | 10.00% | 50.00% | 0.00% | 0.00% | FI | Fixed-Income Portfolio | GR | Growth Portfolio | SPY | 60 | ||||
4 | GLD | 0.00% | 0.00% | 50.00% | 0.00% | RA | Real Assets Portfolio | GR | Growth Portfolio | AGG | 10 | ||||
5 | AAPL | 3.25% | 0.00% | 0.00% | 20.00% | AGGR | Aggressive Portfolio | GR | Growth Portfolio | GLD | 0 | ||||
6 | MSFT | 6.75% | 0.00% | 0.00% | 20.00% | GR | Growth Portfolio | AAPL | 3.25 | ||||||
7 | MINT | 10.00% | 25.00% | 0.00% | 0.00% | GR | Growth Portfolio | MSFT | 6.75 | ||||||
8 | QQQ | 10.00% | 0.00% | 0.00% | 50.00% | GR | Growth Portfolio | MINT | 10 | ||||||
9 | TIP | 0.00% | 25.00% | 25.00% | 0.00% | GR | Growth Portfolio | QQQ | 10 | ||||||
10 | Total | 100% | 100% | 100% | 100% | GR | Growth Portfolio | TIP | 0 | ||||||
11 | FI | Fixed-Income Portfolio | SPY | 0 | |||||||||||
12 | FI | Fixed-Income Portfolio | AGG | 50 | |||||||||||
13 | FI | Fixed-Income Portfolio | GLD | 0 | |||||||||||
14 | FI | Fixed-Income Portfolio | AAPL | 0 | |||||||||||
15 | FI | Fixed-Income Portfolio | MSFT | 0 | |||||||||||
16 | FI | Fixed-Income Portfolio | MINT | 25 | |||||||||||
17 | FI | Fixed-Income Portfolio | QQQ | 0 | |||||||||||
18 | FI | Fixed-Income Portfolio | TIP | 25 | |||||||||||
19 | RA | Real Assets Portfolio | SPY | 25 | |||||||||||
20 | RA | Real Assets Portfolio | AGG | 0 | |||||||||||
21 | RA | Real Assets Portfolio | GLD | 50 | |||||||||||
22 | RA | Real Assets Portfolio | AAPL | 0 | |||||||||||
23 | RA | Real Assets Portfolio | MSFT | 0 | |||||||||||
24 | RA | Real Assets Portfolio | MINT | 0 | |||||||||||
25 | RA | Real Assets Portfolio | QQQ | 0 | |||||||||||
26 | RA | Real Assets Portfolio | TIP | 25 | |||||||||||
27 | AGGR | Aggressive Portfolio | SPY | 10 | |||||||||||
28 | AGGR | Aggressive Portfolio | AGG | 0 | |||||||||||
29 | AGGR | Aggressive Portfolio | GLD | 0 | |||||||||||
30 | AGGR | Aggressive Portfolio | AAPL | 20 | |||||||||||
31 | AGGR | Aggressive Portfolio | MSFT | 20 | |||||||||||
32 | AGGR | Aggressive Portfolio | MINT | 0 | |||||||||||
33 | AGGR | Aggressive Portfolio | QQQ | 50 | |||||||||||
34 | AGGR | Aggressive Portfolio | TIP | 0 | |||||||||||
Models |
Cell Formulas | ||
---|---|---|
Range | Formula | |
B10 | B10 | =SUBTOTAL(109,[GR]) |
C10 | C10 | =SUBTOTAL(109,[FI]) |
D10 | D10 | =SUBTOTAL(109,[RA]) |
E10 | E10 | =SUBTOTAL(109,[AGGR]) |