MS Project data To Excel

kieranbop

New Member
Joined
Sep 13, 2011
Messages
33
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


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
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,224,889
Messages
6,181,608
Members
453,055
Latest member
cope7895

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top