Good afternoon:
Background
Each month, new data is populated in column C on the worksheet titled "Data". The data from column C is copied to the "Report" worksheet. The "Report" worksheet contains historical monthly data but only the most recent 13 months are printed (rolling 13 month report)
I am attempting to pull together some code that will perform the following:
1. Copy column C from "Data" worksheet and paste the column to the next available column on the "Report" worksheet.
2. Adjust the print range to include the new column and the 12 previous columns (to capture the rolling 13 months).
3. Hide the column that is no longer a part of the rolling 13 months (column E in my example)
I recorded a macro and came up with this code but I do not know how to tell the code to find the next available column in the subsequent months in order to perform the paste or how to change the print range the next time the macro is invoked.
Any help would be appreciated.
Todd
Sub CopyPasteDynamicPrint()
'
' CopyPasteDynamicPrint Macro
' Macro recorded 09/29/2006 by Todd Keckhafer
'
'
Sheets("Data").Select
Columns("C:C").Select
Selection.Copy
Sheets("Report").Select
Columns("R:R").Select
Selection.Insert Shift:=xlToRight
ActiveWindow.SmallScroll ToRight:=-8
Range("A1:C130").Select
ActiveWindow.SmallScroll ToRight:=1
ActiveWindow.SmallScroll Down:=-132
Range("F3:R130").Select
Application.CutCopyMode = False
ActiveSheet.PageSetup.PrintArea = "$F$3:$R$130"
End Sub
Background
Each month, new data is populated in column C on the worksheet titled "Data". The data from column C is copied to the "Report" worksheet. The "Report" worksheet contains historical monthly data but only the most recent 13 months are printed (rolling 13 month report)
I am attempting to pull together some code that will perform the following:
1. Copy column C from "Data" worksheet and paste the column to the next available column on the "Report" worksheet.
2. Adjust the print range to include the new column and the 12 previous columns (to capture the rolling 13 months).
3. Hide the column that is no longer a part of the rolling 13 months (column E in my example)
I recorded a macro and came up with this code but I do not know how to tell the code to find the next available column in the subsequent months in order to perform the paste or how to change the print range the next time the macro is invoked.
Any help would be appreciated.
Todd
Sub CopyPasteDynamicPrint()
'
' CopyPasteDynamicPrint Macro
' Macro recorded 09/29/2006 by Todd Keckhafer
'
'
Sheets("Data").Select
Columns("C:C").Select
Selection.Copy
Sheets("Report").Select
Columns("R:R").Select
Selection.Insert Shift:=xlToRight
ActiveWindow.SmallScroll ToRight:=-8
Range("A1:C130").Select
ActiveWindow.SmallScroll ToRight:=1
ActiveWindow.SmallScroll Down:=-132
Range("F3:R130").Select
Application.CutCopyMode = False
ActiveSheet.PageSetup.PrintArea = "$F$3:$R$130"
End Sub