Repeat

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
GalaxyMan
Junior Coder
Posts: 40
Joined: Sat Jun 27, 2009 7:21 pm

Repeat

Post by GalaxyMan » Sat Jun 27, 2009 7:25 pm

I have a table that I want a specific column to be changed. The table can be from 25 to 2500 rows. I need to run my macro and then have it repeat X number of times, which I need to be able to input. If I have 138 rows, I need to be able to tell it to run only 138 times. I have no problems with getting the macro to do what I need to one row, it's all the following rows that I'm having trouble with. I don't understand the Repeat/Until function very well, so VERY specific code would be appreciated.

Thanks in advance...

ainterne
Junior Coder
Posts: 29
Joined: Tue Jun 05, 2007 4:03 am

Post by ainterne » Sun Jun 28, 2009 4:30 am

//Sets the message box size...
Let>MSG_HEIGHT=120
Let>MSG_WIDTH=500

//Repeat a variable....the variable could be k or s or anything you like, however we set the variable to equal 0
Let>k=0

Repeat>k

//Do something, in your case put here the code that allows you do do something once.
//Example, poke something into an Excel spreadsheet.
//Example increase to the next line in a file etc...

Let>Freds_age=k

//So we are going to say that Freds age is 0 to start with.
//Now send a message to screen saying Fred is %k% and getting older.

Message>Fred is %k% years old and will keep going untill he is 138
wait>.1

// So now your code has run once.
// So now increase the variable by 1....

Let>k=k+1

// now the script is going to jump back to Repeat>k at the top with a new value of k+1 untill it reaches 138

Until>k=139

//So now we confirm we have moved on.
MessageModal>Fred has got to %k% and is ready to do something else now.
End
Phil.......

User avatar
GalaxyMan
Junior Coder
Posts: 40
Joined: Sat Jun 27, 2009 7:21 pm

Post by GalaxyMan » Sun Jun 28, 2009 6:10 am

What a fabulous explanation. Even I, not the brightest bulb on the tree, was able to follow it. Many thanks.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts