JR_Chicago
New Member
- Joined
- Apr 20, 2010
- Messages
- 23
Writing loop to create arrays of data associated with like strings with the order of the elements based on loop counter
I have data orientated as follows:
Column A: Header: Product Name (i.e. string data type) ex. "stockA"
Column B: Header: Buy / Sell (i.e. string data type) ex. "Buy" or "Sell"
Column C: Header: Qty Traded (i.e. integer data type) ex. 20
Column D: Header: Price (i.e. integer data type) ex. 712.5
Column E: Header: Trade Date (i.e. date data type) ex. 12/1/09
I have filtered the data so that all the products are in alphabetical ascending order, and all "Buy" trades are in one table and all "Sell" trades are in another table
Example of table:
Buy Table:
stockA Buy 20 712.5 12/1/09
stockA Buy 30 712.0 12/1/09
stockB Buy 10 200.5 12/1/09
stockB Buy 5 200.0 12/1/09
Sell Table:
stockA Sell 20 713.0 12/1/09
stockA Sell 30 713.5 12/1/09
stockB Sell 10 200.5 12/1/09
stockB Sell 5 200.5 12/1/09
I need to write a macro that:
1) Looks at the string in Column A and
2) Creates an array of:
a) Qty traded (on Buy and Sell sides)
b) Trade Prices
Until the string in Column A changes, then, start building new arrays for that product:
I need help writing a loop that will go through Column A, and build the Qty Traded and Trade Price arrays, for each stock in Column A.
Ex. At that at the end of the loop:
qtyBoughtStockA(), tradeBuyStockA()
AND
qtySoldStockA(), tradeSellStockA()
have been created.
The elements of both arrays should be in the order of their occurence.
I will later use the elements in these arrays to compute, Average Trade Price, Total contracts traded, Gross and Net Profits, etc.
Can anyone help?
I'm more than willing to provide any further info that is need to help you visualize the problem.
Thanks.
I have data orientated as follows:
Column A: Header: Product Name (i.e. string data type) ex. "stockA"
Column B: Header: Buy / Sell (i.e. string data type) ex. "Buy" or "Sell"
Column C: Header: Qty Traded (i.e. integer data type) ex. 20
Column D: Header: Price (i.e. integer data type) ex. 712.5
Column E: Header: Trade Date (i.e. date data type) ex. 12/1/09
I have filtered the data so that all the products are in alphabetical ascending order, and all "Buy" trades are in one table and all "Sell" trades are in another table
Example of table:
Buy Table:
stockA Buy 20 712.5 12/1/09
stockA Buy 30 712.0 12/1/09
stockB Buy 10 200.5 12/1/09
stockB Buy 5 200.0 12/1/09
Sell Table:
stockA Sell 20 713.0 12/1/09
stockA Sell 30 713.5 12/1/09
stockB Sell 10 200.5 12/1/09
stockB Sell 5 200.5 12/1/09
I need to write a macro that:
1) Looks at the string in Column A and
2) Creates an array of:
a) Qty traded (on Buy and Sell sides)
b) Trade Prices
Until the string in Column A changes, then, start building new arrays for that product:
I need help writing a loop that will go through Column A, and build the Qty Traded and Trade Price arrays, for each stock in Column A.
Ex. At that at the end of the loop:
qtyBoughtStockA(), tradeBuyStockA()
AND
qtySoldStockA(), tradeSellStockA()
have been created.
The elements of both arrays should be in the order of their occurence.
I will later use the elements in these arrays to compute, Average Trade Price, Total contracts traded, Gross and Net Profits, etc.
Can anyone help?
I'm more than willing to provide any further info that is need to help you visualize the problem.
Thanks.
Last edited: