ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Do...Loop Macro (https://www.excelbanter.com/excel-programming/298343-do-loop-macro.html)

Cass

Do...Loop Macro
 
I have a macro that I want to automatically repeat. How
and where to I plug in the Do Loop.

Ex. I have text that I want to Cut and Paste on a line,
that procedure needs to run about 10 times. How to I tell
my macro to keep repeating itself?

Chip Pearson

Do...Loop Macro
 
Cass,

You would write the code something like

Do Until (some_condition = False)
' your existing code here
Loop

The some_condition depends on your application. This should
return a value of TRUE as long as you want to continue looping.
When some_condition equals FALSE, the loop will terminate and
execution will continue at the first line of code following the
Loop statement.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Cass" wrote in message
...
I have a macro that I want to automatically repeat. How
and where to I plug in the Do Loop.

Ex. I have text that I want to Cut and Paste on a line,
that procedure needs to run about 10 times. How to I tell
my macro to keep repeating itself?




Frank Kabel

Do...Loop Macro
 
Hi
have a look at
For next
in the VBA help

--
Regards
Frank Kabel
Frankfurt, Germany

"Cass" schrieb im Newsbeitrag
...
I have a macro that I want to automatically repeat. How
and where to I plug in the Do Loop.

Ex. I have text that I want to Cut and Paste on a line,
that procedure needs to run about 10 times. How to I tell
my macro to keep repeating itself?




All times are GMT +1. The time now is 08:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com