+ Reply to Thread
Results 1 to 3 of 3

Printing Pages Via Input Box

Hybrid View

  1. #1
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Printing Pages Via Input Box

    Hi,

    I having troubles getting a part of this script to do what I want and was hoping someone could point out what to try.

    What I need is when the user is asked to enter the amount of pallets. The number they input is placed into a cell.

    Here is the problem.

    I'm looking for a way to start at number 1 and work up to the number the user placed in the input box.

    For example if the user put 5 in the input box Range("F37") Would read 5 then in range("A37") the number would read 1.
    Then the page would print ,the next value in Range("A37") would be 2 ,then print and so on up to 5

    So the end result I would have 5 pages that printed with the only differnce being Range("A37") Value being 1,2,3,4,5 .

    Can someone help

    Thanks as always, Mike


    Here is the complete code. Problem is in the pallet code near the bottom.

    Sub Lable()
    Dim strName As String
    Dim cel As Range
    
    
        strName = InputBox(Prompt:="Please Enter Lable", _
              Title:="Lable", Default:="AE")
    
              
    
            If strName = "Your Name here" Or _
               strName = vbNullString Then
    
               Exit Sub
    
            Else
        Set cel = Range("B4")
        cel.FormulaR1C1 = strName
            End If
            
       Call Item_Number
      
    
    End Sub
    
    Sub Item_Number()
    Dim cel As Range, dnumber As String
    dnumber = Application.InputBox(Prompt:="Enter Item Number", Title:="Item Number ?", Type:=1)
    
    Set cel = Range("F4")
    cel.FormulaR1C1 = dnumber
    
    Call Case_Qty
    
    End Sub
    
    Sub Case_Qty()
    Dim cel As Range, dnumber As String
    dnumber = Application.InputBox(Prompt:="Enter Case Qty", Title:="Case Qty ?", Type:=1)
    
    Set cel = Range("A21")
    cel.FormulaR1C1 = dnumber
    
    Call Pallets
    End Sub
    
    Sub Pallets()
    Dim cel As Range, dnumber As String
    Dim PrintPage
    
    dnumber = Application.InputBox(Prompt:="Enter Total Pallets", Title:="Total Pallets ?", Type:=1)
    
    Set cel = Range("F37")
    cel.FormulaR1C1 = dnumber
    PrintPage = dnumber
    
    If PrintPage <> "" Then
    ActiveWindow.SelectedSheets.PrintOut From:=PrintPage, To:=PrintPage, Copies:=1
    End If
    
    End Sub
    Last edited by realniceguy5000; 12-16-2009 at 01:28 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    05-14-2009
    Location
    gold coast
    MS-Off Ver
    Excel 2007
    Posts
    843

    Re: Printing Pages Via Input Box

    hello.

    This may be what you are after
    Sub Pallets()
    Dim x As Integer, dNumber As Integer
    dNumber = Application.InputBox(Prompt:="Enter Total Pallets", Title:="Total Pallets ?", Type:=1)
    If dNumber <> False Then
    Range("F37").Value = dNumber
        For x = 1 To dNumber
            Range("A37").Value = x
            ActiveWindow.SelectedSheets.PrintOut From:=PrintPage, _
                                To:=PrintPage, Copies:=1
        Next x
    End If
    End Sub
    cheers
    Last edited by D_Rennie; 12-16-2009 at 01:07 PM. Reason: typo in code


  3. #3
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Printing Pages Via Input Box

    Quote Originally Posted by D_Rennie View Post
    hello.

    This may be what you are after
    Sub Pallets()
    Dim x As Integer, dNumber As Integer
    dNumber = Application.InputBox(Prompt:="Enter Total Pallets", Title:="Total Pallets ?", Type:=1)
    If dNumber <> False Then
    Range("F37").Value = dNumber
        For x = 1 To dNumber
            Range("A37").Value = x
            ActiveWindow.SelectedSheets.PrintOut From:=PrintPage, _
                                To:=PrintPage, Copies:=1
        Next x
    End If
    End Sub
    cheers
    Thank You for your help. Code works well except this line
    ActiveWindow.SelectedSheets.PrintOut From:=PrintPage, _
                                To:=PrintPage, Copies:=1
    Where I got an error saying you must enter a number between 1 and something. I change the PrintPage to dNumber as the dNumber was declaired and PrintPage wasn't.

    ActiveWindow.SelectedSheets.PrintOut From:=dNumber, To:=dNumber, Copies:=1
    I ran the code with the change I made and the worksheet went through the motions of printing but nothing came out of the printer.

    I then change the code once again to this.

    ActiveSheet.PrintOut
    The worksheets printed correctly so far, I hope I'm not missing something changing the code to just that.

    Anyway thanks for getting me on the right path...

    Mike

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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