View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Tokyo or bust[_2_] Tokyo or bust[_2_] is offline
external usenet poster
 
Posts: 4
Default Simple question - help please and thank you.

Hi Don - thanks for the note - helpful but not exactly what I was looking
for. Here is the code I have thus far - the first line refers to the
numerical month - from a month function in excel - ie.
ActiveSheet.Cells(daily, 1) is equal to 1 for any day in january, 2 for any
day in February etc. I want to do the same operation but reference a
dd/mm/yyyy format, not a number between 1 and 12. Just need help with the
first line........
- hopefuly the below helps to clarify:

If ActiveSheet.Cells(daily, 1) = ActiveSheet.Cells(daily - 1, 1) Then
runningtotal = (1 + (ActiveSheet.Cells(daily, 2))) *
runningtotal
daily = daily + 1

Else

If daily = 10 Then
runningtotal = 1 + ActiveSheet.Cells(daily, 2)
daily = daily + 1
Else
Sheets("MonthlyReturn").Select
ActiveSheet.Cells(Period, 2) = runningtotal - 1
Sheets("data").Select
runningtotal = 1 + ActiveSheet.Cells(daily, 2)
daily = daily + 1
Period = Period + 1

End If
End If






"Don Guillett" wrote:

If you want to sum a month with a formula
=SUMPRODUCT((MONTH(a2:a22)=1)*b2:b22)

a macro to do the same thing and dollar format
Sub sumproductrange()
x = Application.Dollar(Evaluate _
("=SumProduct((Month(rngA) = 1)* rngB)"))
MsgBox x
End Sub
--
Don Guillett
SalesAid Software

"Tokyo or bust" <Tokyo or
wrote in message
...
Hey,

I am calculating simple monthly returns on a series of daily asset prices
for a number of years worth of data. The problem is I am not sure how to
indentify the end of a month, and the start of the next in a column of
05/01/2006 format sequential dates. I could just add another column and
use
the "month" function in excel (what I have done thus far), but I have to
do
the whole operation in VBA. What I have now is:

If ActiveSheet.Cells(dayofmonth, 1) = ActiveSheet.Cells(dayofmonth - 1, 1)
Then day +1 and continue till they are different etc......

The first column is a single number derived from a = month(date column)
formula

This unfortunately will not cut it.

I want to be able to do the same operation, but not have to use the month
function in excel - just reference the date column (04/09/2006 format). I
am
pretty sure I need to use a ActiveCell.Formula and a month function, but
am
unsure as to how to write the formula - any help would be tremendously
appreciated.

Regardless of how easy it is, I have sweat over this for some time.......

Thanks - cheers.