How to Copy Data from one Excel Worksheet to another and Print

Home More Videos

Microsoft Excel Vba Help, How do I print a different sheet?
I have 3 standard sheets in my workbook. I have data in sheet1. From this data I want to create a report based on certain criteria in sheet2 and then print the report in sheet2. I want to use two command buttons in sheet 1. The first command button will create the report in sheet2 and the second button will print the report. What string of code do I need to create a report and then print the sheet2 report? At present I'm working in Excel 2003.
Harry Gonsalves (Goa, India)
The macro code for both the copy (command button 1) and print (command button 2) command buttons is given below:

Private Sub CommandButton1_Click()
x = 2
Do While Cells(x, 1) <> ""
If Cells(x, 4) >= 20000 Then
eRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=Worksheets("Sheet2").Rows(eRow)
End If
x = x + 1
End Sub

Private Sub CommandButton2_Click()
Sheets("Sheet2").PrintOut Copies:=1
End Sub

Watch the training video below to learn how to copy data from one worksheet to another in Excel and print the report using macros attached to command buttons:

Copy Data from one worksheet to another
Print Worksheet

Home More Videos