dragonsorbet
09-05-2011, 09:20 AM
Newbie question. Confession: It has been 22 years since I last used VBA...sigh... I know what I want to do, I have spent hours searching the forum, but I just don't know how to ask the question with the right venecular.
I am building a Day Trading Backtester. I have a large volume of data.
DATE TIME PRICE CONTRACTS
8/29/2011 130233 87.39 1
8/29/2011 130233 87.39 2
8/29/2011 130233 87.39 1
8/29/2011 130233 87.39 4
8/29/2011 130233 87.38 1
8/29/2011 130233 87.37 2
8/29/2011 130233 87.37 1
I want to sum all of the contracts for the time between 130200 and 130300 (for example). The number of rows I want to sum will change with each time increment.
I have built an Overview page to operate from. On that page, I have a named range Starting_Row and Ending_Row. By using an IF statement in my VB code, I determine that the contracts to be summed are from rows 17 to 34. So on my Overview page in address B1 (Starting_Row named range) is the value 17 and in B2 (Ending_Row named range) is the value 34. I want to put the answer in location B4 on the overview page.
My code reads:
ActiveWorkbook.Names.Add Name:="Starting_Row", RefersToR1C1:="=Overview!B1"
Range("B4").Activate
ActiveCell = "=SUM(D17.D34)"
Obviously this works...but only once. Because I want to continue going through the data and changing the values in B1 and B2 to the next range of data, I want to substitue in two variables in for the last statement. I want to do something like this:
ActiveCell = "=SUM(Starting_Row,EndingRow)"
I know this is wrong, what I don't know is what is right and even how to ask the question. :confused:
The Ole Dragon thanks for your help!!
I am building a Day Trading Backtester. I have a large volume of data.
DATE TIME PRICE CONTRACTS
8/29/2011 130233 87.39 1
8/29/2011 130233 87.39 2
8/29/2011 130233 87.39 1
8/29/2011 130233 87.39 4
8/29/2011 130233 87.38 1
8/29/2011 130233 87.37 2
8/29/2011 130233 87.37 1
I want to sum all of the contracts for the time between 130200 and 130300 (for example). The number of rows I want to sum will change with each time increment.
I have built an Overview page to operate from. On that page, I have a named range Starting_Row and Ending_Row. By using an IF statement in my VB code, I determine that the contracts to be summed are from rows 17 to 34. So on my Overview page in address B1 (Starting_Row named range) is the value 17 and in B2 (Ending_Row named range) is the value 34. I want to put the answer in location B4 on the overview page.
My code reads:
ActiveWorkbook.Names.Add Name:="Starting_Row", RefersToR1C1:="=Overview!B1"
Range("B4").Activate
ActiveCell = "=SUM(D17.D34)"
Obviously this works...but only once. Because I want to continue going through the data and changing the values in B1 and B2 to the next range of data, I want to substitue in two variables in for the last statement. I want to do something like this:
ActiveCell = "=SUM(Starting_Row,EndingRow)"
I know this is wrong, what I don't know is what is right and even how to ask the question. :confused:
The Ole Dragon thanks for your help!!