I recently managed to get data from MS excel to map out in a preset Gantt chart of my choosing. so on the click it will send corresponding cells from excel to ms project. See code below
That was run from a module from excel that worked when you clicked a button. Read all data from sheet "Coursebookings" in that excel
Now I was wondering how I would go about if i changed a few Gantt dates or something like that. At the click of a macro starting in project, write out information back to an excel sheet called "bringmeback" or something along those lines.
Any help to ideas would be really appreciated
That was run from a module from excel that worked when you clicked a button. Read all data from sheet "Coursebookings" in that excel
Now I was wondering how I would go about if i changed a few Gantt dates or something like that. At the click of a macro starting in project, write out information back to an excel sheet called "bringmeback" or something along those lines.
Any help to ideas would be really appreciated
Code:
Sub proJ()
Dim proJ As MSProject.Application
Dim aProJ As MSProject.Project
Set proJ = CreateObject("MSProject.Application")
Dim strAnalysis, strApplication, strStartDate, strEndDate, strDeadDate As String
Dim strCluster, strCores, strSpace As String
Dim strPriority As String
Dim i As Long
Dim t As Task
With proJ
.FileOpen "S:\Information\Design Systems Engineering\Open Access Data\HPC\Admin\HPC Gantt Blank.mpp"
.Application.Visible = True
End With
Set aProJ = proJ.activeproject
'Delete Existing tasks
For Each t In aProJ.Tasks
t.Delete
Next t
For i = 2 To ActiveSheet.Cells(Rows.Count, 3).End(xlUp).Row
strAnalysis = Worksheets("Course Bookings").Range("E" & i)
strApplication = Worksheets("Course Bookings").Range("F" & i)
strCluster = Worksheets("Course Bookings").Range("L" & i)
strCores = Worksheets("Course Bookings").Range("M" & i)
strSpace = Worksheets("Course Bookings").Range("N" & i)
strStartDate = Worksheets("Course Bookings").Range("I" & i)
strEndDate = Worksheets("Course Bookings").Range("K" & i)
strDeadDate = Worksheets("Course Bookings").Range("J" & i)
strPriority = Worksheets("Course Bookings").Range("H" & i)
'Add task i
aProJ.Tasks.Add(strAnalysis).Text3 = strAnalysis
'change field of current task i
aProJ.Tasks(i - 1).Text4 = strApplication
aProJ.Tasks(i - 1).Start = strStartDate
aProJ.Tasks(i - 1).Finish = strEndDate
aProJ.Tasks(i - 1).Deadline = strDeadDate
aProJ.Tasks(i - 1).Text1 = strCluster
aProJ.Tasks(i - 1).Number3 = strCores
aProJ.Tasks(i - 1).Number2 = strSpace
aProJ.Tasks(i - 1).OutlineCode1 = strPriority
Next i
End Sub