I have a double nested Do loop consisting of an outer and inner do loop. I'm having trouble passing values from the outer loop to the inner loop. A simplified version of my procedure is:
Option Explicit
Sub A()
Dim t as integer
t=0
Do
lines of code
Worksheets (1).Range("A1").Value = t
Do While (Condition is Satisfied)
lines of code
Worksheets (1).Range("A2").Value = t
Loop
t = t + 1
Loop Until t = 41
End Sub
The purpose of the program is to write the final value of t in the outer loop in Cell A1, and the final value of t in the inner loop in Cell A2.
Both values should equal 40. However, the value of 40 is placed in Cell A1 and the value of 0 is placed in Cell 2. Apparently the value of t is not being passed from the outer loop to the inner loop.
Is there anyone that can help me solve this problem?
Option Explicit
Sub A()
Dim t as integer
t=0
Do
lines of code
Worksheets (1).Range("A1").Value = t
Do While (Condition is Satisfied)
lines of code
Worksheets (1).Range("A2").Value = t
Loop
t = t + 1
Loop Until t = 41
End Sub
The purpose of the program is to write the final value of t in the outer loop in Cell A1, and the final value of t in the inner loop in Cell A2.
Both values should equal 40. However, the value of 40 is placed in Cell A1 and the value of 0 is placed in Cell 2. Apparently the value of t is not being passed from the outer loop to the inner loop.
Is there anyone that can help me solve this problem?