+ Reply to Thread
Results 1 to 5 of 5

Print button fucntion to determine if 2 copies or 3 copies are printed

Hybrid View

  1. #1
    Registered User
    Join Date
    05-01-2014
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    5

    Print button fucntion to determine if 2 copies or 3 copies are printed

    I have a print button on sheet 1 that when clicked performs the operation below. I also have 2 option buttons in a group (Yes/No) that returns a value of either 1 or 2 in D26. I would like to be able to click the print button on sheet and if the option 1 (Yes) which returns value of 1 to D26 is selected then print 3 copies of sheet 2 if no is selected then just stick with the operation below. Thanks

    Private Sub butPrint_Click()

    Sheets("Sheet2").Select
    Sheets("Sheet2").Range("I2").Value = _
    Sheets("Sheet2").Range("I2").Value + 1

    ActiveWindow.SelectedSheets.PrintOut Copies:=2, Collate:=True, _
    IgnorePrintAreas:=False

    Sheets("Sheet1").Select
    End Sub

  2. #2
    Forum Contributor yay_excel's Avatar
    Join Date
    08-12-2011
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    190

    Re: Print button fucntion to determine if 2 copies or 3 copies are printed

    Please use code tags as per forum rules.

    You will need to set a boolean variable for whether D26 is true or false:
    Dim OptionYes as Boolean
    Test D26
    If Range("D26") = "1" Then OptionYes = True
    Then on your print method you need to adjust the Copies parameter accordingly. I would assign another variable to store the number of copies.
    Dim NumberCopies as Integer
    If OptionYes Then 
         NumberCopies = 3
    Else
         NumberCopies = 2
    End If
    
    ActiveWindow.SelectedSheets.PrintOut Copies:=NumberCopies

  3. #3
    Forum Contributor
    Join Date
    01-25-2011
    Location
    Virginia
    MS-Off Ver
    Excel 2016
    Posts
    166

    Re: Print button fucntion to determine if 2 copies or 3 copies are printed

    How about:
    Private Sub butPrint_Click()
    
     Sheets("Sheet2").Select
     Sheets("Sheet2").Range("I2").Value = _
     Sheets("Sheet2").Range("I2").Value + 1
    
     If Range("D26") = 1 Then
       ActiveWindow.SelectedSheets.PrintOut Copies:=3, Collate:=True, IgnorePrintAreas:=False
     Else
       ActiveWindow.SelectedSheets.PrintOut Copies:=2, Collate:=True, IgnorePrintAreas:=False
     End If
     Sheets("Sheet1").Select
     End Sub
    Regards,

    Tom

  4. #4
    Forum Contributor yay_excel's Avatar
    Join Date
    08-12-2011
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    190

    Re: Print button fucntion to determine if 2 copies or 3 copies are printed

    You don't HAVE to use variables (as per tom's code) but it is easier to understand when you're learning if you do.

  5. #5
    Registered User
    Join Date
    05-01-2014
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Print button fucntion to determine if 2 copies or 3 copies are printed

    Works great thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Print Userform: Control number of Copies Printed
    By yunesm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-15-2010, 08:34 AM
  2. Multiple copies being printed
    By trishm in forum Excel General
    Replies: 1
    Last Post: 03-12-2009, 01:14 PM
  3. Replies: 1
    Last Post: 12-07-2008, 12:21 PM
  4. Print number of copies box
    By EMoe in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-08-2005, 11:09 AM
  5. sequential numbering of copies printed
    By brian in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-11-2005, 06:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1