How to Use VBA to Group and Transpose Data...

F

fzl2007

This is just a sample of my data for two customers:

A B C D E
1 Quarter CustomerID ProdID Sales
2 20080930 Cust813 p1221 532
3 20080930 Cust813 p3368 2322
4 20080930 Cust813 p4340 2339
5 20081231 Cust813 p3368 778378
6 20081231 Cust813 p4340 8626
7 20081231 Cust813 p2150 132
8 20090331 Cust813 p4230 309
9 20090630 Cust813 p3368 1767
10 20090630 Cust813 p4340 1245


13 20080930 Cust866 p5526 6838
14 20080930 Cust866 p7204 7146
15 20081231 Cust866 p3368 7778
16 20081231 Cust866 p4230 8626
17 20081231 Cust866 pF577 132
18 20090331 Cust866 pG105 309
19 20081231 Cust866 p4340 1767
20 20120630 Cust866 p2150 1245
21 …


Results Desired:
20080930 20081231 20090331 20090630
Cust813 0.992731937 90.23626246 1.419277108
Cust866 4.401810979

0.992731937 is the result of E3/E4 (2322/2339)
90.23626246 is the result of E5/E6
4.401810979 is the result of E15/E19

I need to transpose the quarter date as column and for each customerID, I want to see the result of calculations of their ProdID p3368 / ProdID p4340 (for other cases, it will be more variables involved).

Should I do this using sql stored procedures since I am not so sure how to handle it in excel...

Maybe I can group it by CustomerID and then search for the ProdID but I don't know how to transpose Qarter Date is to show once only.

I appreciate any suggestions.

Faye
 
Top