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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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,223,646
Messages
6,173,531
Members
452,520
Latest member
Pingaware

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