VBA print x number of copies based on number specified in a cell

chelseasikoebs

Board Regular
Joined
Mar 9, 2009
Messages
61
I have two worksheets that we print off weekly. However, the quantity of pages we print each week changes. I would like to have a cell that asks for the number of copies to print, then after my existing script runs through changes on the sheet, it'll automatically print x number of copies that was specified in that cell. Any ideas?
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Should be easy if you just add one line to your code:

Code:
ActiveSheet.Printout  Copies:=Range("A1").Value

Or
Code:
For x = 1 to Range("A1").Value
    ActiveSheet.Printout
Next x

I suppose you may want to add some validation - is A1 a number, is it greater than 0? Is it less than a maximum allowed number? Or have the number of copies entered at runtime with an input box.
 
Upvote 0
Hi there,

Run the following on the sheet in question. It will print that sheet the number of times that is in cell A2 (change as required):

Code:
Sub Macro1()

    With ActiveSheet
        .PrintOut Copies:=Range("A2").Value
    End With
    
End Sub

HTH

Robert
 
Upvote 0
Code:
Sub Macro1()

    With ActiveSheet
        .PrintOut Copies:=Range("A2").Value
    End With
    
End Sub
HTH

Robert[/QUOTE]


I get a runtime error 1004 when I add this to the end of my other script. If I run it as a separate macro, it works. Why would that be?
 
Upvote 0

Forum statistics

Threads
1,213,504
Messages
6,114,016
Members
448,543
Latest member
MartinLarkin

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