1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Excel User Input Boxes

Discussion in 'Business Applications' started by downhillsheep, Apr 25, 2012.

Thread Status:
Not open for further replies.
Advertisement
  1. downhillsheep

    downhillsheep Thread Starter

    Joined:
    Apr 25, 2012
    Messages:
    2
    I have this macro that prints records based on a range that the user specifies. The only problem is that I'm still (trying to!) learning and would like to know how the code can be written so that the input box with ".....Starting Record" appears before and not after the input box ".......End Record" which is what is happening at the moment.

    VB:
    Sub Print_All()
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    Dim x As Variant
    Dim v As Variant
    v = InputBox("Please enter the Ending Record number")
    For i = InputBox("Please enter the Starting Record number") To v
    x = i
    Range("n2").FormulaR1C1 = x
    Sheets("Deskingsheet").Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
    IgnorePrintAreas:=False

    Next i
    End Sub

    Thanks in advance

    Lee ​
     
  2. Ziggy1

    Ziggy1

    Joined:
    Jun 17, 2002
    Messages:
    2,532
    this is what I would do...


    VB:
    Code:
    Sub Print_All() 
    Application.Calculation = xlCalculationAutomatic 
    Application.ScreenUpdating = False 
    Application.DisplayAlerts = False 
    Dim x As Variant 
    Dim v As Variant 
    
    i = InputBox("Please enter the Starting Record number") 
    v = InputBox("Please enter the Ending Record number") 
    x = i 
    For i =x To v 
    
    Range("n2").FormulaR1C1 = x 
    Sheets("Deskingsheet").Select 
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _ 
    IgnorePrintAreas:=False 
    
    x= x +1
    Next i 
    End Sub 
     
  3. downhillsheep

    downhillsheep Thread Starter

    Joined:
    Apr 25, 2012
    Messages:
    2
    Hi Ziggy, many thanks for your help, it worked a treat
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1050752