AndrewGKenneth
Board Regular
- Joined
- Aug 6, 2018
- Messages
- 59
Hi there,
I have created macro in VBA to run a loop to go through each task on my Microsoft Project file and perform a calculation. The macro is doing exactly what I want it to do but appears to be running in an infinite loop when I call it with the project change / worksheet change function. Could anyone help me understand why? Here is my code below:
Option Explicit
Sub myloop()
Dim tsk As Task
For Each tsk In ActiveProject.Tasks
If Not (tsk Is Nothing) Then
On Error Resume Next
tsk.Number3 = Val(tsk.Number2) / Val(tsk.Number1)
tsk.Number3 = tsk.Number3 * 100
tsk.PercentWorkComplete = tsk.Number3
End If
Next tsk
End Sub
Thanks in advance for your help,
Kind Regards,
Andrew
I have created macro in VBA to run a loop to go through each task on my Microsoft Project file and perform a calculation. The macro is doing exactly what I want it to do but appears to be running in an infinite loop when I call it with the project change / worksheet change function. Could anyone help me understand why? Here is my code below:
Option Explicit
Sub myloop()
Dim tsk As Task
For Each tsk In ActiveProject.Tasks
If Not (tsk Is Nothing) Then
On Error Resume Next
tsk.Number3 = Val(tsk.Number2) / Val(tsk.Number1)
tsk.Number3 = tsk.Number3 * 100
tsk.PercentWorkComplete = tsk.Number3
End If
Next tsk
End Sub
Thanks in advance for your help,
Kind Regards,
Andrew