PC Review


Reply
Thread Tools Rate Thread

copying macros to other sheets

 
 
esilverb
Guest
Posts: n/a
 
      25th Jun 2008
I have a button that runs a macro taking data from the active sheet and
putting it in a separate summary sheet and then printing the summary sheet. I
want to put a button on every sheet in the workbook that will do the exact
same thing - take the data from that sheet, put it on the summary sheet and
then print the summary sheet. How do I copy the button and the macro so that
it will work on each sheet?
Note: the macro begins by clearning out the summary sheet so the new data
gets put into a clean worksheet.
Thanks for your help.

 
Reply With Quote
 
 
 
 
FSt1
Guest
Posts: n/a
 
      25th Jun 2008
hi
it might be helpful if you posted your current code.

regard
FSt1

"esilverb" wrote:

> I have a button that runs a macro taking data from the active sheet and
> putting it in a separate summary sheet and then printing the summary sheet. I
> want to put a button on every sheet in the workbook that will do the exact
> same thing - take the data from that sheet, put it on the summary sheet and
> then print the summary sheet. How do I copy the button and the macro so that
> it will work on each sheet?
> Note: the macro begins by clearning out the summary sheet so the new data
> gets put into a clean worksheet.
> Thanks for your help.
>

 
Reply With Quote
 
esilverb
Guest
Posts: n/a
 
      25th Jun 2008
Here's the code
Sub Print_Sheet()
'
' Print_Sheet Macro
'

'
Sheets("Sheet1").Select
Range("A1:A2").Select
Selection.ClearContents
Range("G1:G2").Select
Selection.ClearContents
Range("A4:G16").Select
Selection.ClearContents
Sheets("8P-2 Stivers").Select
Range("A1:A2").Select
Selection.Copy
Sheets("Sheet1").Select
Range("A1").Select
ActiveSheet.Paste
Sheets("8P-2 Stivers").Select
Range("A4:A16").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
Range("A4").Select
ActiveSheet.Paste
Sheets("8P-2 Stivers").Select
Range("F4:F16").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
Range("B4").Select
ActiveSheet.Paste
Sheets("8P-2 Stivers").Select
Range("G4:G16").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
Range("C4:C16").Select
ActiveSheet.Paste
Sheets("8P-2 Stivers").Select
ActiveWindow.SmallScroll ToRight:=8
Range("L4:M16").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
Range("D4").Select
ActiveSheet.Paste
Sheets("8P-2 Stivers").Select
ActiveWindow.LargeScroll ToRight:=2
ActiveWindow.SmallScroll ToRight:=-10
Range("U4:V16").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
Range("F4").Select
ActiveSheet.Paste
Sheets("8P-2 Stivers").Select
Range("T17").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
Range("G1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

"FSt1" wrote:

> hi
> it might be helpful if you posted your current code.
>
> regard
> FSt1
>
> "esilverb" wrote:
>
> > I have a button that runs a macro taking data from the active sheet and
> > putting it in a separate summary sheet and then printing the summary sheet. I
> > want to put a button on every sheet in the workbook that will do the exact
> > same thing - take the data from that sheet, put it on the summary sheet and
> > then print the summary sheet. How do I copy the button and the macro so that
> > it will work on each sheet?
> > Note: the macro begins by clearning out the summary sheet so the new data
> > gets put into a clean worksheet.
> > Thanks for your help.
> >

 
Reply With Quote
 
FSt1
Guest
Posts: n/a
 
      25th Jun 2008
hi
sorry it took so long to get back. i got hung up.
looks like you did this on record so i cleaned up up a bit by commenting out
the unnecessary stuff and consolidating. you should see what i commented out.
should be faster. no flopping back and forth.
sheet1 seems to be the summary sheet so everything is geared to paste there.
select what ever sheet you want then run the macro. so long as you so that,
this macro will work with any sheet.
As to the button on each sheet. put the code below in a standard module. for
the button code do this....
Private Sub CommandButton1_Click()
Call Print_Sheet
End Sub
then copy the button to each sheet. you may have to add the "call
print_sheet".

TEST this on a dummy copy of your file BEFORE you try it on LIVE data.

sub Print_Sheets()
'Sheets("Sheet1").Select
Sheets("sheet1").Range("A1:A2").ClearContents
Sheets("sheet1").Range("G1:G2").ClearContents
Sheets("sheet1").Range("A4:G16").ClearContents
'Sheets("8P-2 Stivers").Select
Range("A1:A2").Copy Destination:= _
Sheets("sheet1").Range("A1")
'Range("A1:A2").Copy
'Sheets("Sheet1").Select
'Range("A1").Select
'ActiveSheet.Paste
'Sheets("8P-2 Stivers").Select
Range("A4:A16").Copy Destination:= _
Sheets("Sheet1").Range("A4")
'Range("A4:A16").Select
'Application.CutCopyMode = False
'Selection.Copy
'Sheets("Sheet1").Select
'Range("A4").Select
'ActiveSheet.Paste
'Sheets("8P-2 Stivers").Select
Range("F4:F16").Copy Destination:= _
Sheets("Sheet1").Range("B4")
'Range("F4:F16").Select
'Application.CutCopyMode = False
'Selection.Copy
'Sheets("Sheet1").Select
'Range("B4").Select
'ActiveSheet.Paste
'Sheets("8P-2 Stivers").Select
Range("G4:G16").Copy Destination:= _
Sheets("Sheet1").Range("C4:C16")
'Range("G4:G16").Select
'Application.CutCopyMode = False
'Selection.Copy
'Sheets("Sheet1").Select
'Range("C4:C16").Select
'ActiveSheet.Paste
'Sheets("8P-2 Stivers").Select
'ActiveWindow.SmallScroll ToRight:=8
Range("L4:M16").Copy Destination:= _
Sheets("sheet1").Range("D4")
'Range("L4:M16").Select
'Application.CutCopyMode = False
'Selection.Copy
'Sheets("Sheet1").Select
'Range("D4").Select
'ActiveSheet.Paste
'Sheets("8P-2 Stivers").Select
'ActiveWindow.LargeScroll ToRight:=2
'ActiveWindow.SmallScroll ToRight:=-10
Range("U4:V16").Copy Destination:= _
Sheets("Sheet1").Range("F4")
'Range("U4:V16").Select
'Application.CutCopyMode = False
'Selection.Copy
'Sheets("Sheet1").Select
'Range("F4").Select
'ActiveSheet.Paste
'Sheets("8P-2 Stivers").Select
Range("T17").Copy
Sheets("Sheet1").Select
'Range("T17").Select
'Application.CutCopyMode = False
'Selection.Copy
'Sheets("Sheet1").Select
Range("G1").PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, SkipBlanks:=False, _
Transpose:=False

End Sub

regards
FSt1

"esilverb" wrote:

> Here's the code
> Sub Print_Sheet()
> '
> ' Print_Sheet Macro
> '
>
> '
> Sheets("Sheet1").Select
> Range("A1:A2").Select
> Selection.ClearContents
> Range("G1:G2").Select
> Selection.ClearContents
> Range("A4:G16").Select
> Selection.ClearContents
> Sheets("8P-2 Stivers").Select
> Range("A1:A2").Select
> Selection.Copy
> Sheets("Sheet1").Select
> Range("A1").Select
> ActiveSheet.Paste
> Sheets("8P-2 Stivers").Select
> Range("A4:A16").Select
> Application.CutCopyMode = False
> Selection.Copy
> Sheets("Sheet1").Select
> Range("A4").Select
> ActiveSheet.Paste
> Sheets("8P-2 Stivers").Select
> Range("F4:F16").Select
> Application.CutCopyMode = False
> Selection.Copy
> Sheets("Sheet1").Select
> Range("B4").Select
> ActiveSheet.Paste
> Sheets("8P-2 Stivers").Select
> Range("G4:G16").Select
> Application.CutCopyMode = False
> Selection.Copy
> Sheets("Sheet1").Select
> Range("C4:C16").Select
> ActiveSheet.Paste
> Sheets("8P-2 Stivers").Select
> ActiveWindow.SmallScroll ToRight:=8
> Range("L4:M16").Select
> Application.CutCopyMode = False
> Selection.Copy
> Sheets("Sheet1").Select
> Range("D4").Select
> ActiveSheet.Paste
> Sheets("8P-2 Stivers").Select
> ActiveWindow.LargeScroll ToRight:=2
> ActiveWindow.SmallScroll ToRight:=-10
> Range("U4:V16").Select
> Application.CutCopyMode = False
> Selection.Copy
> Sheets("Sheet1").Select
> Range("F4").Select
> ActiveSheet.Paste
> Sheets("8P-2 Stivers").Select
> Range("T17").Select
> Application.CutCopyMode = False
> Selection.Copy
> Sheets("Sheet1").Select
> Range("G1").Select
> Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
> SkipBlanks _
> :=False, Transpose:=False
>
> "FSt1" wrote:
>
> > hi
> > it might be helpful if you posted your current code.
> >
> > regard
> > FSt1
> >
> > "esilverb" wrote:
> >
> > > I have a button that runs a macro taking data from the active sheet and
> > > putting it in a separate summary sheet and then printing the summary sheet. I
> > > want to put a button on every sheet in the workbook that will do the exact
> > > same thing - take the data from that sheet, put it on the summary sheet and
> > > then print the summary sheet. How do I copy the button and the macro so that
> > > it will work on each sheet?
> > > Note: the macro begins by clearning out the summary sheet so the new data
> > > gets put into a clean worksheet.
> > > Thanks for your help.
> > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying sheets without copying named ranges NMACK08 Microsoft Excel Programming 1 5th Feb 2008 08:53 PM
RE: Macros - copying macros from one computer to another =?Utf-8?B?VFQ=?= Microsoft Excel Misc 2 14th Dec 2006 03:24 AM
RE: Macros - copying macros from one computer to another =?Utf-8?B?VFQ=?= Microsoft Excel Misc 0 14th Dec 2006 02:26 AM
Re: Macros - copying macros from one computer to another Gord Dibben Microsoft Excel Misc 2 8th Dec 2006 09:36 PM
Copying sheets with names, macros and functions =?Utf-8?B?UGhpbGxpcCBHb3VsZA==?= Microsoft Excel Misc 3 19th Mar 2004 01:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:31 AM.