+ Reply to Thread
Results 1 to 5 of 5

Loop not working

Hybrid View

blankus Loop not working 07-13-2009, 04:54 PM
shg Re: Loop not working 07-13-2009, 05:03 PM
blankus Re: Loop not working 07-13-2009, 05:45 PM
shg Re: Loop not working 07-13-2009, 06:01 PM
blankus Re: Loop not working 07-14-2009, 04:16 AM
  1. #1
    Registered User
    Join Date
    12-18-2008
    Location
    Malta
    Posts
    14

    Loop not working

    HI

    So i have a user form asking for a From and To and the text boxes are currently name textbox1 and textbox2. A sheet called Pack Voucher picks up information from an other sheet called Packs List. I am basically asking the user to enter which pack voucher needs printing and print 2 copies of each Pack voucher.

    I came up with the following code by it is not working can someone help me..

    Private Sub OK_Click()
        Dim ws As Worksheet
        Set ws = Worksheets("PACK VOUCHER")
    
        
        Application.ScreenUpdating = False
        sono = TextBox1.Value
        ws.Range("K1").Value = sono.Value
        
        Do Until sono = TextBox2.Value
        
        ws.Range("K1").Value = sono.Value
        ActiveSheet.PrintOut Copies:=2
        sono = sono + 1
        Loop
        Sheets("PACKS LIST").Select
        Application.ScreenUpdating = True
        
    Unload Me
    End Sub
    I am quite sure that i have to define the "sono" but don't know where....can u help me out plssssssssss...


    Franco
    Last edited by blankus; 07-13-2009 at 05:18 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Loop not working

    Please take a few minutes to read the forum rules, and then edit your post to add code tags.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    12-18-2008
    Location
    Malta
    Posts
    14

    Re: Loop not working

    is the edit post ok??

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Loop not working

    Yes, thanks.

    Not sure if this is what you want:
    Private Sub OK_Click()
        Dim ws      As Worksheet
        Dim i       As Long
    
        If IsNumeric(TextBox1.Value) And _
           IsNumeric(TextBox2.Value) Then
    
            Set ws = Worksheets("PACK VOUCHER")
            Application.ScreenUpdating = False
    
            For i = TextBox1.Value To TextBox2.Value
                ws.Range("K1").Value = i
                ActiveSheet.PrintOut Copies:=2
            Next i
            
            Sheets("PACKS LIST").Select
            Application.ScreenUpdating = True
            Unload Me
        End If
    End Sub

  5. #5
    Registered User
    Join Date
    12-18-2008
    Location
    Malta
    Posts
    14

    Re: Loop not working

    yeap....GREAT....IT WORKED JUST THE WAY I WANTED....THANKS A REAL LOT

+ 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