Hi,
I have a macro I previously wrote that creates a monthly log file for 10 pump stations. It copies the daily reads from a file where some cells are populated from a SQL server and some manually. Each station has it's own sheet and the file is named for the month, ex. "Feb-2003.xls". A button on the Daily Reads sheet creates (on the 1st of new month) and/or updates the monthly log. This works great except I have to manually copy & paste last months final reads forward. Problem code follows:
Workbooks.Open (LastMonthFile)
Sheets(Array("S-2", "S-4", Etc. 10 stations total).Select
Worksheets("S-2"
.Range(?:?).Select
' How do I set up this range, I have a variable
' representing the last day of the month and row to copy.
' I need something like
' Worksheets("S-2"
.Range("C" LastDay:"N" LastDay).Select
' Column range is C to N.
Selection.Copy
Windows(CurrentMonth).Activate ' Current month is already open
Range("C6"
.Select
ActiveSheet.Paste
Windows(LastMonth).Activate
ActiveWindow.Close
I'm sure this is easy but, I just can't see it.
Any help would be appreciated.
renigar
I have a macro I previously wrote that creates a monthly log file for 10 pump stations. It copies the daily reads from a file where some cells are populated from a SQL server and some manually. Each station has it's own sheet and the file is named for the month, ex. "Feb-2003.xls". A button on the Daily Reads sheet creates (on the 1st of new month) and/or updates the monthly log. This works great except I have to manually copy & paste last months final reads forward. Problem code follows:
Workbooks.Open (LastMonthFile)
Sheets(Array("S-2", "S-4", Etc. 10 stations total).Select
Worksheets("S-2"
' How do I set up this range, I have a variable
' representing the last day of the month and row to copy.
' I need something like
' Worksheets("S-2"
' Column range is C to N.
Selection.Copy
Windows(CurrentMonth).Activate ' Current month is already open
Range("C6"
ActiveSheet.Paste
Windows(LastMonth).Activate
ActiveWindow.Close
I'm sure this is easy but, I just can't see it.
Any help would be appreciated.
renigar