Create separate print button for each worksheet in Excel

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
I HAVE THREE WORKSHEET S1, S2 AND S3, AND I WANT PRINT S1 ON BUTTON ONE, S2 ON BUTTON TWO, AND S3 ON BUTTON THREE. CAN ANY ONE HELP ME ABOUT THIS. THANK IN ADVANCE.
 
Upvote 0
I HAVE DIFFERENT WORKSHEET, AND I WANT TO CREATE PRINT BUTTON IN EACH WORKSHEET. THANKS IN ADVANCE

Run this top macro. It adds a button to cell F2 on each worksheet and assigns the Print_Sheet macro to print that sheet when clicked.

VBA Code:
Public Sub Add_Print_Button_To_All_Worksheets()

    Dim ws As Worksheet
    Dim printButton As Button
    
    For Each ws In ThisWorkbook.Worksheets
        Set printButton = ws.Buttons.Add(ws.Range("F2").Left, ws.Range("F2").Top, 80, 20)
        printButton.Name = "Print sheet"
        printButton.Caption = "Print " & ws.Name
        printButton.OnAction = "Print_Sheet"
    Next
    
End Sub


Public Sub Print_Sheet()
    ActiveSheet.PrintOut Copies:=1
End Sub
 
Upvote 0
thanks for your kind reply, but sir in each worksheet there is diffrent ranges e.g starting from A2 to M2, and it print only the range where there is text/values diplayed by formula not the formulas. thanks in advance
 
Upvote 0
I don't understand your last reply, but maybe change Print_Sheet to:

VBA Code:
Public Sub Print_Sheet()
    ActiveSheet.UsedRange.PrintOut Copies:=1
End Sub
 
Upvote 0
1712651593850.png

I HAVE THREE WORKSHEET S1, S2 AND S3, AND I WANT PRINT S1 ON BUTTON ONE, S2 ON BUTTON TWO, AND S3 ON BUTTON THREE. CAN ANY ONE HELP ME ABOUT THIS. THANK IN ADVANCE.
sir here the report may vary according to the selection in the drop box ............. therefore i want to print only report not extra blank rows i.e. here i want to print it from A2 TO J14 ONLY. THANKS
 
Upvote 0
Thanks for clarifying. Replace the Print_Sheet code with:

VBA Code:
Public Sub Print_Sheet()
    Dim lastRow As Long
    With ActiveSheet
        lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
        .Range("A2:J" & lastRow).PrintOut Copies:=1
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,248
Messages
6,123,873
Members
449,130
Latest member
lolasmith

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