Macro Copy


Posted by Rob on August 15, 2001 12:22 PM

I have a sheet with a button, linked to a macro which prints. This sheet is being copied (like a template) then data being put in. The new copied sheets have buttons, but the buttons are not linked to print. Is there a way to do this automatically? Or maybe modify my print code so that 1 macro works for the active sheet? heres my code.

Sub PrintMacro2()
Dim rPrintRange As Range

If Range("A3") = "" Then Exit Sub

Set rPrintRange = Range("A1", Range("H65536").End(xlUp))

With ActiveSheet.PageSetup
.PrintArea = rPrintRange.Address
.FitToPagesTall = 1
.FitToPagesWide = 1
.Orientation = xlLandscape
End With

Set rPrintRange = Nothing

ActiveSheet.PrintOut
ActiveSheet.DisplayPageBreaks = False
End Sub


Thanks

Posted by Robb on August 15, 2001 4:04 PM

Rob

What sort of buttons are you using. If you use Command Buttons in Excel 97 onwards, and place your code in the Button_Click event of the Worksheet, the buttons and their code will be copied.

Does this do the trick?

Regards



Posted by Rob on August 15, 2001 4:27 PM

Thanks again!

What sort of buttons are you using. If you use Command Buttons in Excel 97 onwards, and place your code in the Button_Click event of the Worksheet, the buttons and their code will be copied. Does this do the trick? Regards

: I have a sheet with a button, linked to a macro which prints. This sheet is being copied (like a template) then data being put in. The new copied sheets have buttons, but the buttons are not linked to print. Is there a way to do this automatically? Or maybe modify my print code so that 1 macro works for the active sheet? heres my code. : Sub PrintMacro2() : Dim rPrintRange As Range : If Range("A3") = "" Then Exit Sub : Set rPrintRange = Range("A1", Range("H65536").End(xlUp)) : With ActiveSheet.PageSetup : .PrintArea = rPrintRange.Address : .FitToPagesTall = 1 : .FitToPagesWide = 1 : .Orientation = xlLandscape : End With : Set rPrintRange = Nothing : ActiveSheet.PrintOut : ActiveSheet.DisplayPageBreaks = False : End Sub : : Thanks