Microsoft Project - VBA

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
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You probably need to look at the Worksheet_Change code and set Application.EnableEvents to False near the start of the code and reset it to True at the end.
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,701
Members
448,980
Latest member
CarlosWin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top