user2533223
user2533223

Reputation:

How can I create a VBA code to print our multiple copies of the same sheet?

I have a button in excel and I want it to print an X amount of copies. Like Say 10 so items come into stock. I want to print 10 copies. I have formula that looks up the item info. I just want a code that Prints so many times for the "quantity" that I will fill in.

Upvotes: 0

Views: 10856

Answers (2)

Alan Waage
Alan Waage

Reputation: 624

ActiveWindow.SelectedSheets.PrintOut Copies:=Range("A1").Value

Upvotes: 2

Andy G
Andy G

Reputation: 19367

Essentially..

Sub PrintXCopies()
    ActiveSheet.PrintOut , , Range("A1").Value
End Sub

where the number of copies to print is in cell A1. You should add error-handling in case this is not a number, or a sensible number. Something like:

Sub PrintXCopies()
    If IsNumeric(Range("A1").Value) Then
        If Range("A1").Value >= 1 And Range("A1").Value < 10 Then
            ActiveSheet.PrintOut , , Range("A1").Value
        End If
    End If
End Sub

Upvotes: 1

Related Questions