create some VBA code to replace Duration values with Duration1 val

K

Kathleen

Hi
I am using MS PRoject Server 2003 and would like to create some VBA code
that you could place on
a toolbar button to automate the process and replace Duration values
with Duration1 values. can anyone help me with this?

I was in the Server group and got this far:
The issue that I have is that I need the Duration field to mimic the
Duration1 duration so the gantt bars will be accurate.


Currently the fields look like this

Text1 Duration Duration1
Med 1 day? 20 days

Then the Gantt bar for that task is 1 day
Switch([Text1]="Not
Set",[Duration],[Text1]="High",14400,[Text1]="Medium",9600,[Text1]="Small",4800)

Because the Duration fields show values in minutes, I had to multiply
the 30 days by 480 (8 hours times 60 minutes) to get the value for 30
days.

The result in the Duration1 field:
Tasks with a Text1 value = "Not Set" just show the Duration
Tasks with a Text1 value = "High" show 30 days
Tasks with a Text1 value = "Medium" show 20 days
Tasks with a Text1 value = "Small" show 10 days

Thanks
Kathleen
 
R

Rod Gill

You can't add a formula to the Duration field so try recording a macro of
you copying all data in Duration1 to Duration.

The following will also work:

Sub CopyDur1
Dim Tsk as Task
For Each Tsk in ActiveProject.Tasks
If Not Tsk is Nothing Then 'Test for empty rows
Tsk.Duration=Tsk.Duration1
End If
Next
End Sub

--

Rod Gill
Project MVP

NEW!! Project VBA Book, for details visit: http://www.projectvbabook.com


Kathleen said:
Hi
I am using MS PRoject Server 2003 and would like to create some VBA code
that you could place on
a toolbar button to automate the process and replace Duration values
with Duration1 values. can anyone help me with this?

I was in the Server group and got this far:
The issue that I have is that I need the Duration field to mimic the
Duration1 duration so the gantt bars will be accurate.


Currently the fields look like this

Text1 Duration Duration1
Med 1 day? 20 days

Then the Gantt bar for that task is 1 day
Switch([Text1]="Not
Set",[Duration],[Text1]="High",14400,[Text1]="Medium",9600,[Text1]="Small",4800)

Because the Duration fields show values in minutes, I had to multiply
the 30 days by 480 (8 hours times 60 minutes) to get the value for 30
days.

The result in the Duration1 field:
Tasks with a Text1 value = "Not Set" just show the Duration
Tasks with a Text1 value = "High" show 30 days
Tasks with a Text1 value = "Medium" show 20 days
Tasks with a Text1 value = "Small" show 10 days

Thanks
Kathleen
 
B

BillB

Public Sub SetDuration()
Dim t as task
For each t in activeproject.tasks
if not t is nothing then
with t
if .Text1= "High" then
.Duration = 30 * ActiveProject.HoursPerDay * 60 ' show 30
days
elseif .Text1 = "Medium" then
.Duration = 20 * ActiveProject.HoursPerDay * 60 ' show 20
days
elseif .Text1 = "Small" then
.Duration = 10 * Activeproject.HoursPerDay * 60 ' show 10
days
end if
end with
end if
next t
end sub

Stick it in a module and make a button for it.

Bill B

Kathleen said:
Hi
I am using MS PRoject Server 2003 and would like to create some VBA code
that you could place on
a toolbar button to automate the process and replace Duration values
with Duration1 values. can anyone help me with this?

I was in the Server group and got this far:
The issue that I have is that I need the Duration field to mimic the
Duration1 duration so the gantt bars will be accurate.


Currently the fields look like this

Text1 Duration Duration1
Med 1 day? 20 days

Then the Gantt bar for that task is 1 day
Set",[Duration],[Text1]="High",14400,[Text1]="Medium",9600,[Text1]="Small",4
800)
Thanks
Kathleen
 

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