I have a problem using for
loop in this MS Project VBA Macro:
Sub Check_Change_Article() Dim ProjTasks As Tasks Dim ProjTask As Task Dim Art As String Dim ArtOld As String Set ProjTasks = ActiveProject.Tasks ArtOld = " " For Each ProjTask In ProjTasks If Not (ProjTask Is Nothing) Then Art =ProjTask.Text22 If (Art != ArtOld) Then ProjTask.Text4 = "CHANGE" End If ArtOld = Art End If Next ProjTask End Sub
Project Example
Case 1: Sheet when task is open: VBA Row # TaskID Text22 Text4 1 1 PNL50R CHANGE 2 2 PNL50R 3 3 JPL50Y CHANGE
Case 2: User can filter, group or order tasks (note change in row number) VBA Row # TaskID Text22 Text4 1 3 PNL50R CHANGE 2 1 PNL50R CHANGE 3 2 JPL50Y
I read this discussion: ms project VBA associate task with row
Using ActiveSelection.Tasks
instead of ActiveProject.Tasks
I see that for
loop iterates follow VBA Rows.
Is it possible to set for a loop to iterate by VBA Row Number, without using ActiveSelection
(if it's possible, I wouldn't force the user to select rows)?
Thanks in advance, Giuseppe