In excel I have the ID' numbers in column "A" starting on the second row (first row=header). In column "T" I have a duration for that ID on the same row.
In MS Project I have an ID column and an empty duration column. I want to add the duration from excel to MS Project on the correct ID row.
I think I can do this by using tasks and a For..To loop. I will need to use the ID in excel to look up the task in MS Project then write the duration from excel in the appropriate task in MS Project. So far, with some help, the code I have is:
'Find duration and assign to ID in Excel
For i = 2 To lastRow
date1 = .Cells(i, 15)
date2 = .Cells(i, 16)
If .Cells(i, 18).Value = "No" Then
answer = DateDiff("n", date1, date2)
.Cells(i, 20) = answer
End If
durationID = .Cells(i,1).Value
Next i
'Open MS Project and add Duration column
set wb = ActiveWorkBook
Set ws = wb.Sheets("Task_Table1")
Set appProj = CreateObject("Msproject.Application")
appProj.FileOpen "File1.mpp"
Set aProg = appProj.ActiveProject
appProj.Visible = True
lastTask = ActiveProject.Tasks.Count
taskID = ActiveProject.Tasks.ID
'Load Durations into MS Project to appropriate ID task
lastTask = ActiveProject.Tasks.Count
For i = 1 to lastTask
If taskID = Application.Workbooks("File1").Sheets("Task_Table1").Cells(i, 1).Value Then
answer.Copy
appProj.SelectCell.ActiveCell
end if
Next i