-
Apr 13th, 2018, 10:35 AM
#1
Thread Starter
New Member
[WORD] Temporarily store a varaible
Hi all. I have stored in my normal.dot a 6 macros that I need to run in succession. Each macro has an InputBox command that retrieves a variable from the user for the number of times to loop. Let's assume I enter the number "8". The next macro in succession that I need to run also needs to loop the same number of times, and the one following that does also... and so on. Is there a way for me to save the variable from the first InputBox statement so I don't have to keep reentering it with the next 6 macros that I need to run?
Dim Message, Title, Default, IterationCount
Message = "How many iterations do you wish to perform?" ' Set prompt.
Title = "Iterations" ' Set title.
Default = "1" ' Set default.
IterationCount = InputBox(Message, Title, Default)
For LoopCount = 1 To IterationCount 'Loop
.
.
.
Next LoopCount
-
Apr 13th, 2018, 12:14 PM
#2
Re: [WORD] Temporarily store a varaible
Change the scope of your Count variable:
Code:
Dim IterationCount As Integer
Private Sub sub1()
IterationCount = InputBox("How many iterations?", "Iterations", 1)
'...
Call sub2
End Sub
Private Sub sub2()
MsgBox IterationCount
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|