vba question to change start dates

T

theintern

Can anyone tell me why it give me an error on the second to last line?

Dim t1 As Task
Dim t2 As Task
Dim ts As Tasks
Set ts = ActiveProject.Tasks
Set t1 = ts(1)
Set t2 = ts(2)
While Not (t2.Name = "")
Set t1 = ts(t2.ID - 1)
If t1.ResourceInitials = t2.ResourceInitials Then
t2.Start = t1.Finish
End If
t2 = ts(t2.ID + 1)
Wend

thanks!
 
J

Jan De Messemaeker

Hi,

First, In VBA shouldn't that read set t2=ts(T2.id+1) ?
Second, it will try to get to the task index higher than the number of
elements in ts.

Why not:

for each t2 in Ts
if not t2 is nothing then
if t2.id>1 then
set t1=ts(t2.id-1)
.....

end if
end if
next t2


--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
 
T

theintern

Thanks!

Jan De Messemaeker said:
Hi,

First, In VBA shouldn't that read set t2=ts(T2.id+1) ?
Second, it will try to get to the task index higher than the number of
elements in ts.

Why not:

for each t2 in Ts
if not t2 is nothing then
if t2.id>1 then
set t1=ts(t2.id-1)
.....

end if
end if
next t2


--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top