+ Reply to Thread
Results 1 to 4 of 4

Print number of pages based on cell value

Hybrid View

  1. #1
    Registered User
    Join Date
    06-14-2018
    Location
    LONDON
    MS-Off Ver
    2007
    Posts
    29

    Print number of pages based on cell value

    Hi,

    Not sure if anyone can help, is it possible to print pages based on a cell value with VBA.

    So if cell A1 contained “0” then 0 pages/copy’s would be printed, if A1 then contained “4” four pages would print?

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,438

    Re: Print number of pages based on cell value

    .
    This works with the "activesheet" .. which can be any sheet you want. Cell "A1" of that sheet must have the number of times you want
    the printer to print.

    Option Explicit
    
    Sub PrntXTimes()
        ActiveSheet.PrintOut , Copies:=Sheet1.Range("A1").Value
    End Sub

    Here is another method that allows the user more flexibility :

    Sub PrntPrview()
     Application.CommandBars.ExecuteMso ("PrintPreviewAndPrint")
    End Sub

  3. #3
    Registered User
    Join Date
    06-14-2018
    Location
    LONDON
    MS-Off Ver
    2007
    Posts
    29

    Re: Print number of pages based on cell value

    Hi Thanks for your help,

    This is what I have, so the copies is cells O4 - O9, they all have different page ranged.

    The print will be exercuted from sheet1, the print range is in sheet 2, the copies value is in sheet1. I have no idea why this isn't working, are you able to assist?

    When running these I get runtime error 1004 Method 'range of object' '_worksheet' failed


    Sub PrintPLTLABLE1()
    
    Range("A1:B11").PrintOut , Copies:=Sheet1.Range("04").Value
    
    End Sub
    
    Sub PrintPLTLABLE2()
    
    Range("A12:B22").PrintOut , Copies:=Sheet1.Range("05").Value
    
    End Sub
    
    Sub PrintPLTLABLE3()
    
    Range("A23:B33").PrintOut , Copies:=Sheet1.Range("06").Value
    
    End Sub
    Sub PrintPLTLABLE4()
    
    Range("A34:B44").PrintOut , Copies:=Sheet1.Range("07").Value
    
    End Sub
    
    Sub PrintPLTLABLE5()
    
    Range("A45:B55").PrintOut , Copies:=Sheet1.Range("08").Value
    
    End Sub
    
    Sub PrintPLTLABLE6()
    
    Range("A56:B66").PrintOut , Copies:=Sheet1.Range("09").Value
    
    End Sub

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,438

    Re: Print number of pages based on cell value

    .
    Sub PrintPLTLABLE1()
    Dim numrow As Long
    Dim i As Long
    Dim runmacro
        runmacro = Application.InputBox("How many print copies?", "Enter a number", , , , , , 1)
        
        If IsNumeric(numrow) Then
            For i = 1 To runmacro
                Range("A1:B11").PrintOut
            Next i
        End If
    End Sub

+ 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 a specific number of pages based on cell value
    By janger in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-19-2020, 10:14 AM
  2. Edit print macro to be based on number of pages in Sheet
    By KT999 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-06-2014, 10:25 AM
  3. set number of pages to print based on data on the page
    By MATT.B in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-05-2014, 05:33 PM
  4. [SOLVED] Print "X" number of pages based on a cell value.
    By Spencerk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-21-2014, 07:46 PM
  5. [SOLVED] Macro to print number of pages based on cell
    By Webbers in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-24-2012, 02:15 PM
  6. print pages based on number in cell
    By lpratt in forum Excel General
    Replies: 3
    Last Post: 01-10-2012, 08:08 PM
  7. Print number of pages based on cell value
    By Rene Pronk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-19-2011, 07:46 AM

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