Hung,
I don't know exactly what you want it to do, but it looks like your
if...then statements are not correct.
Should be
if (something) then
'do stuff
end if
The way you have it constructed they are nested. Nothing will happen unless
the first condition is true.
Also, all of the first line of the if...then statement should be on the same
line. You can break it up into multiple lines using the line continuation
character _ but you have not done this or perhaps your news poster has
broken the lines.
Just guessing what you are after I'd make the following changes. I think I'd
try and clean it up some more.
You know that you need to go to the project menu/project information dialog
box and set the status date for your project first right?
Sub lalala()
Dim t As Task
Dim ts As Tasks
Dim sDate as date
Set ts = ActiveProject.Tasks
sDate = activeproject.statusdate
For Each t In ts
If Not t Is Nothing Then
If ((PercentComplete > 0) And (PercentComplete < 100)) Then
t.Text25 = "Group2"
End if
If ((t.Start > sDate) And _
(t.Start < (sDate+ 7))) _
Or ((t.Finish > sDate) And _
(t.Finish < (sDate+ 7))) Then
t.Text25 = "Group1"
End if
If ((t.Start > sDate+ 8) And _
(t.Start < (sDate+ 14))) _
Or ((t.Finish > sDate+ 8) And _
(t.Finish < (sDate+ 14))) Then
t.Text25 = "Group3"
End if
If ((t.Start > sDate+ 15) And _
(t.Start < (sDate+ 35))) _
Or ((t.Finish > sDate+ 15) And _
(t.Finish < (sDate+ 35))) Then
t.Text25 = "Group4"
if t.Text25 = "" then
t.text25 = "Group5"
end if
Next t
GroupApply Name = "myGroup"
End Sub