Excel 2010 Active Sheet Print Macro

Tendon

New Member
Joined
Jun 15, 2011
Messages
3
An Excel 2010 workbook contains worksheets that receive user input. I am looking for help with creating a macro that will force the printing of only the sheets that received input.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
What do you mean by "force the printing"? Automatically print when the user closes the workbook? When do you want to enforce your will upon the hapless soles?

What do you exactly mean by "only the sheets that received input"? Since the workbook was opened?
 
Upvote 0
AlphaFrog, Thank you for your reply. My workbook contains 10 worksheets. Each worksheet has cells that the user enters data such as quantity of an item. Most times only one or two sheets in the workbook have been selected during a use session. My goal is to have a button that will cause only the sheets that have data input to be printed and not print sheets that received no inputs.

Thank you for your continue assistance.
 
Upvote 0
Put this at the top of any standard VBA module; e.g. Module1
Code:
Public strPrintSheets As String

Put this in the ThisWorkbook module.
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    If InStr(strPrintSheets, Sh.Name & ",") = 0 Then strPrintSheets = strPrintSheets & Sh.Name & ","
End Sub

Put this in the sheet module that will have your Print commandbutton
Code:
Private Sub CommandButton1_Click()

    Dim ws As Variant
    If Not strPrintSheets = vbNullString Then
        ws = Split(Left(strPrintSheets, Len(strPrintSheets) - 1), ",")
        Sheets(ws).PrintOut Copies:=1, Collate:=True
        strPrintSheets = vbNullString 'Clear worksheet change list after print?
    Else
        MsgBox "No changed sheets to print.", vbExclamation, "Print Sheets Canceled"
    End If

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,700
Members
452,938
Latest member
babeneker

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