Hi All
I am trying to read task updates from Excel using a copy of some VBA code kindly posted on the web but it does not write anything back to the project plan even though it is picking up the data in Excel ok. A copy of the code is shown below. Any help/guidance appreciated.
Tony
Sub Update_MSP() Dim xlstartdate, xlfinishdate, puid As String Dim xlpercentcomplete As Integer Dim xlduration As Integer Dim prstartdate, prfinishdate As Date Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook Dim xlSheet As Excel.Worksheet Dim Proj As Project Dim t As Task Dim Asgn As Assignment Dim i, j, c1 As Integer '************************************ 'NEED TO SKIP SUMMARY TASKS 'ADD CODE TO SKIP THESE '************************************ 'open the source workbook, read only Set xlBook = Workbooks.Open("D:\CPP Build Template\CPP Build Plans\MPS Plans WIP\Update from Excel Test\Book1.xlsx", True, True) c1 = 3 Do While Sheets("Sheet1").Cells(c1, 1) <> "" 'read data from excel file starting from row 2 'and format start date to start at 8 AM and finish date to finish at 5PM puid = Sheets("Sheet1").Cells(c1, 3) ' Unique id xlstartdate = (Sheets("Sheet1").Cells(c1, 5)) ' Excel file Start date in dd/mm/yyyy format xlfinishdate = CDate(Sheets("Sheet1").Cells(c1, 7)) ' Excel file Finish date in dd/mm/yyyy format xlpercentcomplete = CDate(Sheets("Sheet1").Cells(c1, 11)) ' Excel percentcomplete xlduration = CDate(Sheets("Sheet1").Cells(c1, 9)) ' Excel file Finish date in dd/mm/yyyy format c1 = 3 For Each t In ActiveProject.Tasks If t.Summary = False Then ' find the excel file unique id in the Project file based on uniqueid and update ' actual start, actual finish, perecent complete and duration If t.UniqueID = puid Then t.ActualStart = xlstartdate t.ActualFinish = xlfinishdate t.PercentComplete = xlpercentcomplete t.Duration = xlduration 'need to exit the code once found to the next line in the excel sheet Exit For End If End If Next t c1 = c1 + 1 Loop End Sub