Defining "Month" as a variable in VBA

C

Colin Vicary

Hi All

I'm trying to write a macro that will look at 12 monthly sales columns
and sum the year to date sales.

I think I'm defining the month as a variable with..

Dim Mon As Integer
Mon = Month(today)

But I get very stange results when I use this to calculate the
sales...

Range("W1").Select
ActiveCell.FormulaR1C1 = "Sales LYTD"
With ActiveSheet.Range("W2:W" & LastRow)
..FormulaR1C1 = "=SUM(RC[-12]:RC[-" & (12 - Mon) & "])"
End With

Any idea what I need to change?

Thanks

Colin (ever amazed by my own lack of knowledge!)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top