Backup to a second sheet and then print

basher

New Member
Joined
Apr 19, 2011
Messages
19
Hello,

I am looking to build a macro to take the values from two cells of the sheet "Label" and paste them in the first empty row on the sheet "Labels Printed". I was able to use macro record so that when I hit ctrl+p it copies the 2 cells over and prints the label but it copies over the last row Which I would like to prevent.

Code:
Sub Macro4()
'
' Macro4 Macro
' Macro recorded 4/19/2011 by LENOVO-StoreOps
'
' Keyboard Shortcut: Ctrl+p
'
    Range("D4:F4").Select
    Selection.Copy
    Sheets("Labels Printed").Select
    Range("A2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("Label").Select
    Range("A6:F6").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Labels Printed").Select
    Range("B2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("A3").Select
    Sheets("Label").Select
    Application.CutCopyMode = False
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub

Thank You,
Matthew Brown
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try

Code:
Sub Macro4()
'
' Macro4 Macro
' Macro recorded 4/19/2011 by LENOVO-StoreOps
'
' Keyboard Shortcut: Ctrl+p
'
    Range("D4:F4").Copy
    Sheets("Labels Printed").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
    Sheets("Label").Range("A6:F6").Copy
    Sheets("Labels Printed").Range("B" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
    Sheets("Label").PrintOut
End Sub
 
Upvote 0
Try

Code:
Sub Macro4()
'
' Macro4 Macro
' Macro recorded 4/19/2011 by LENOVO-StoreOps
'
' Keyboard Shortcut: Ctrl+p
'
    Range("D4:F4").Copy
    Sheets("Labels Printed").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
    Sheets("Label").Range("A6:F6").Copy
    Sheets("Labels Printed").Range("B" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
    Sheets("Label").PrintOut
End Sub

Thanks! It works if I run it with VBE but the CTRL + P shorcut no longer works?

Also is there a way that it can automaticlly save after it backsup?

Thank you,
Matthew Brown
 
Upvote 0
If you go to run the macro but instead of Run click Options you should be able to set the shortcut key combination.


To save try

Code:
Sub Macro4()
'
' Macro4 Macro
' Macro recorded 4/19/2011 by LENOVO-StoreOps
'
' Keyboard Shortcut: Ctrl+p
'
    Range("D4:F4").Copy
    Sheets("Labels Printed").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
    Sheets("Label").Range("A6:F6").Copy
    Sheets("Labels Printed").Range("B" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
    Sheets("Label").PrintOut
    ThisWorkbook.Save
End Sub
 
Upvote 0
Thanks that worked great! One more thing then I will dissapear. It worked with ctrl + P but I forgot.... what if someone clicks the printer Icon? Is there away to backup and auto save if they do that?

Thank you,
Matthew Brown
 
Upvote 0
Yes: press ALT + F11 to open the Visual Basic Editor, double click on ThisWorkbook in the Project window and paste in

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel=True
Application.EnableEvents=False
Call Macro4
Application.EnableEvents=True
End Sub
 
Upvote 0
Hello VoG,

I did this and it printed but thats it. It did not back up or save. I hit alt + F11 Double clicked and pasted into ThisWorkbook:


Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
Application.EnableEvents = False
Call Macro4
Application.EnableEvents = True
End Sub
Code:
Sub Macro4()
'
' Macro4 Macro
' Macro recorded 4/19/2011 by LENOVO-StoreOps
'
' Keyboard Shortcut: Ctrl+p
'
    Range("D4:F4").Copy
    Sheets("Labels Printed").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
    Sheets("Label").Range("A6:F6").Copy
    Sheets("Labels Printed").Range("B" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
    Range("D4").Value = Range("D4") + 1
    ThisWorkbook.Save
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,672
Members
452,937
Latest member
Bhg1984

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top