View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H. Mike H. is offline
external usenet poster
 
Posts: 471
Default Adding the next month to a daily volume tracking sheet.

This should work, depending on how you have the dates running, ascending or
descending. This will work for ascending. It assumes each A1 is 4/1/08 for
each sheet when you enter a date of 5/1/08

Sub AddMo()
Dim wSheet As Worksheet
Dim NewMonth As Date
Dim NextMonth As Date
Dim Lastmonth As Date
Dim DayInMo As Integer
Dim TheName As String

Let NewMonth = InputBox("Please enter the New Month in MM/DD/YYYY format
please: 05/01/2008, etc.")
Let Lastmonth = DateAdd("m", -1, NewMonth)
Let NextMonth = DateAdd("m", 1, NewMonth)
Let DayInMo = NextMonth - NewMonth

Application.ScreenUpdating = False
For Each wSheet In Worksheets
Let TheName = wSheet.Name
Sheets(TheName).Select
If Cells(1, 1).Value = Lastmonth Then
Rows("1:" & DayInMo).Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
For X = 1 To DayInMo
Cells(X, 1).Value = NewMonth + X - 1
Next
Cells(1, 1).Select
End If
Next wSheet

End Sub


"mjmcevoy" wrote:

Hello,

Im trying to automate a tedious task at work but Im not sure how to go
about it.

We track daily volumes on a spreadsheet.

Column 1 would have each business day for the month. Column 2 through 8
would have various volumes for different items that we enter each day. This
piece cant be automated do to the source of the volumes but what I would
like to automate is adding the next month to the top of the sheet and moving
the previous month down. I cant simply copy and paste the previous month
because the number of business days in each month varies. I would also like
to add the busness days.

The thing that makes this so tedious is that it has to be done on several
sheets.

Any suggestions would be appreciated.

Mike