Hi!
i'm trying to creat a macro that add new rows base on date.
evertime i hit ctrl+shift+A it will add new row to column A and B. and Column A will get this days of date.
and if it go to next month Column A,B,C and D will get new row as well. A get the days date. and Column C got the days Month(this mounth = 10). and Column D will Get the total of Column B base on Month.
the data is like this.
so far i manage to add new row in column A and B but can't get the C to work.
i hope u guys understand what i mean and my skills on vba is very poor.
ths in advance
i'm trying to creat a macro that add new rows base on date.
evertime i hit ctrl+shift+A it will add new row to column A and B. and Column A will get this days of date.
and if it go to next month Column A,B,C and D will get new row as well. A get the days date. and Column C got the days Month(this mounth = 10). and Column D will Get the total of Column B base on Month.
the data is like this.
Code:
columnA columnB ColumnC ColumnD
date value month total
2012-02-05 255 2012-02 255
2012-01-05 254 2012-01 708
2012-01-02 154
2012-01-01 300
Code:
Sub NewDay()
' NewDay Macro
' Keyboard Shortcut: Ctrl+Shift+A
Range("A2:B2").Copy
Range("A2:B2").Insert shift:=xlDown, Copyorigin:=xlFormatFromRightOrBelow
Range("A2:B2").PasteSpecial xlPasteFormulasAndNumberFormats
Range("B2").ClearContents
Range("A2").Value = Now()
If DateSerial(Year(Date), Month(Date), Day("")) > Range("C2").DataSeries Then
Range("C2:D2").Insert shift:=xlDown, Copyorigin:=xlFormatFromRightOrBelow
Range("C2:D2").PasteSpecial xlPasteFormulasAndNumberFormats
Range("C2").Value = DateSerial(Now(), Now(), "")
End If
End Sub
so far i manage to add new row in column A and B but can't get the C to work.
i hope u guys understand what i mean and my skills on vba is very poor.
ths in advance
Last edited: