ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Executing a subroutine from within a loop (https://www.excelbanter.com/excel-programming/349875-executing-subroutine-within-loop.html)

Jeff@DE

Executing a subroutine from within a loop
 
This should work but it does not. The macro just steps over the
subroutine
message without executing it. What am I missing?

-VBA 2003

dim ii as integer

For ii=1 to 3
message
next ii

Public Sub Message()
MsgBox "Time to take a break!"
End Sub


Ken Johnson

Executing a subroutine from within a loop
 
Hi Jeff,
it worked for me. Of course I had to copy the loop into a blank Sub
that I've called MessageRunner

Public Sub MessageRunner()
Dim ii As Integer

For ii = 1 To 3
Message
Next ii
End Sub

Public Sub Message()
MsgBox "Time to take a break!"
End Sub

Ken Johnson



All times are GMT +1. The time now is 05:06 PM.

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