Skip to main content

Hey Community,

I was wondering if it is possible to make a loop which runs a small part of my script run a specific amount of times? with this i mean that if my script pick up the number 2 then it should run the rest of the script twice, and if it reads the number 3 then it should run the script 3 times.

 

currently my script is reading something from Excel putting it into a database which comes up with a different number everytime, when this number is generated then i would like that whatever i have in my script after it has read the number should be run accordingly to this.

I hope this makes sense and that somebody can help me out with my problem thanks beforehand.

 

 


#Rumba

Hey Community,

I was wondering if it is possible to make a loop which runs a small part of my script run a specific amount of times? with this i mean that if my script pick up the number 2 then it should run the rest of the script twice, and if it reads the number 3 then it should run the script 3 times.

 

currently my script is reading something from Excel putting it into a database which comes up with a different number everytime, when this number is generated then i would like that whatever i have in my script after it has read the number should be run accordingly to this.

I hope this makes sense and that somebody can help me out with my problem thanks beforehand.

 

 


#Rumba

 - If I'm understanding correctly, I believe that what you want to do can be achieved with a Do-Loop.

 

Sub myProcedure()

  Dim intRepeat as Integer
  Dim intCount as Integer

  ' Some code here....

  intRepeat = ' Get number from database
  intCount = 0

  ' Loop through your code as many times as you like
  Do While intCount < intRepeat

    ' Some code here...

    intCount = intCount 1

  Loop


End Sub