General discussion

Locked

VBA Help NEEDED Please

By emil.hovsepyan ·
hi, i am afraid this is an important one that needs doing asap, so for all you techies out there thanks in advance for your response.
the scenario is:
In MS Project i have numberous columns which include a "Start Date" and "Completed". its a simple task, i need a little VBA code that will go through my columns and see if the start date is less than today() and if completed <> 0 then change the colour of the row to red.. sounds simple enough.. do i need to use arrays or something?? i am lost people.. please help..thanks again

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

I Don't have any experience with M$ Project, but...

by jkameleon In reply to VBA Help NEEDED Please

... I've done a lot of things with VBA on Access, Excel, Word etc. The best way to get yourself un-lost is to record a macro of whathever you want to do:

- Tools/Macro/Record new Macro...
- change dates, color or whatever
- Tools/Macro/Stop Recording

Then you open the VBA editor (Tools/Macro/Visual Basic Editor), find macro you've just recorded, parametrize it, add a couple of If's & For's, run it, and enjoy the show.

Collapse -

thanks

by emil.hovsepyan In reply to I Don't have any experien ...

hi, i tried that, but the code doesnt seem to work, and plus i think selecting using your mouse is different from creating an array to look for it no??

Collapse -

Sorry

by jkameleon In reply to thanks

With all that hundreds or maybe thousand miles of cable between us, I'm afraid I can't help you any more than I've already had. Visual Basic Editor has pretty decent debugging features as well. Use them. For starters, you could click that gray band on the left of program code, breakpoint will appear.

Collapse -

Try this -

by arild In reply to VBA Help NEEDED Please

Hi Emil,

a couple of years since I was looking into MS Project, but this code should hopefully get you started:

Sub Test()
Dim b, c As Date
Dim ta, I As Long
Dim myTask As String

'Get Number of tasks in project
ta = ActiveProject.Tasks.Count
' Loop over all tasks
For I = 1 To ta

' Read the "Start" field for Task I
b = ActiveProject.Tasks.Item(I).Start
' Read the "Finish" field for Task I
c = ActiveProject.Tasks.Item(I).Finish

' Use line numbers to position
SelectTaskField Row:=I, Column:="Finish", RowRelative:=False

' compare your date fields, use colored text
If b < c Then
Font Bold:=True, Color:=8 ' dark red bold text
End If

Next I

End Sub

Back to Windows Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums