Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jul 2008
    Location
    Suffolk, United Kingdom
    Posts
    308
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to loop a set number (2003)

    Hi,

    How do you use the loop function to loop a piece of vba code the amount of times entered into an input box

    Thanks
    Regards
    Gerbil (AKA Kevin)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: How to loop a set number (2003)

    You can use the For ... Next loop for that:

    Dim intMax As Integer
    Dim intLoop As Integer

    intMax = Val(InputBox("How many times?"))
    For intLoop = 1 To intMax
    ' Your code here
    MsgBox "This is loop number " & intLoop
    Next intLoop

Posting Permissions

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