Quantcast
Channel: Project Customization and Programming forum
Viewing all articles
Browse latest Browse all 5347

how to extract timescale data to excel in ms project 2010

$
0
0

Hello,

i've been trying to customize the visual report to get the data i need but i learnt that its not that customizable. i found this macro online but i dont have alot of knowledge to alter it properly to match my needs. the macro is working but the dates are not showing by the hours spent on tasks.

what i want to show is the following:

- Work/actual work/remaining work/ Dates where the hours were spent and planned/ cost.

below is the macro and thank you for any help and feedback.

Sub PhasedResourceData()

 ' Sub will export timephased resource data (work, cost) into Microsoft Excel worksheet
 'The output is data in Excel spreadsheet, which you can then use to create a pivot table.
 
' Define time interval for timephased data

 Dim Start, Finish As String
 Start = "1.1.2013"
 Finish = "31.12.2013"
 
' Define timescale unit. Can be one of the following PjTimescaleUnit constants:
 '   pjTimescaleYears, pjTimescaleQuarters, pjTimescaleMonths, pjTimescaleWeeks,
 ' pjTimescaleDays, pjTimescaleHours, pjTimescaleMinutes
 Dim TimescaleUnit As PjTimescaleUnit
 TimescaleUnit = pjTimescaleMonths
 
Dim Pj As Project
 Dim PjRes As Resources
 Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet

 Dim IdSheet As Integer
 
 
Set Pj = ActiveProject
 Set PjRes = Pj.Resources
 
Set xlApp = New Excel.Application
 xlApp.Visible = False

 Set xlBook = xlApp.Workbooks.Add
 xlBook.Title = Pj.Title
 Set xlSheet = xlBook.ActiveSheet
 
Dim TSVWork As TimeScaleValues
 Dim TSVCost As TimeScaleValues
 Dim T As Long
 Dim R As Long
 Dim Row As Integer
 
 
' Choose work unit divisor depending on the Tools | Options | Schedule | Work.
 ' Work is stored in minutes in MS Project.
 Select Case Pj.DefaultWorkUnits
 Case pjMinute
 d = 1
 Case pjHour
 d = 60
 Case pjDay
 d = Pj.HoursPerDay * 60
 Case pjWeek
 d = Pj.HoursPerWeek * 60
 Case pjMonthUnit
 d = Pj.DaysPerMonth * Pj.HoursPerDay * 60
 Case Else
 d = 1
 End Select
 
' Set up currency format for Excel
 CurrencyFormat = SetCurrencyFormat(Pj)
 
If Pj.Resources.Count > 0 Then
 
xlSheet.Cells(1, 1) = "Group"
 xlSheet.Cells(1, 2) = "Resource"
 xlSheet.Cells(1, 3) = "Date"
 xlSheet.Cells(1, 4) = "Work"
 xlSheet.Cells(1, 5) = "Cost"
 
Row = 2
 
For R = 1 To Pj.Resources.Count
 Set TSVWork = PjRes(R).TimeScaleData(Start, Finish, _
 Type:=pjResourceTimescaledWork, TimescaleUnit:=TimescaleUnit)
 Set TSVCost = PjRes(R).TimeScaleData(Start, Finish, _
 Type:=pjResourceTimescaledCost, TimescaleUnit:=TimescaleUnit)
 
For T = 1 To TSVWork.Count
 
If Not TSVWork(T).Value = "" And Not TSVCost(T).Value = "" Then
 xlSheet.Cells(Row, 2) = PjRes(R).Name
 xlSheet.Cells(Row, 3) = TSVWork(T).StartDate
 Select Case TimeUnits
 Case pjTimescaleMonths
 xlSheet.Cells(Row, 3).NumberFormat = "Mmm Yy"""
 End Select
 
If Not TSVWork(T).Value = "" Then
 xlSheet.Cells(Row, 4) = TSVWork(T).Value / d
 xlSheet.Cells(Row, 4).NumberFormat = "#,##0"
 End If
 If Not TSVCost(T).Value = "" Then
 xlSheet.Cells(Row, 5) = TSVCost(T).Value
 xlSheet.Cells(Row, 5).NumberFormat = CurrencyFormat
 End If
 
Row = Row + 1
 
End If
 
Next T
 Next R
 
End If
 
xlApp.ScreenUpdating = True
 MSProject.ScreenUpdating = True
 'and finally display a message that we are finished
 AppActivate "Microsoft Project"
 
xlApp.Visible = True
 AppActivate "Microsoft Excel"
 End Sub
 
Function SetCurrencyFormat(Pj As Project)
 
' Set currency number format
 CurrencyFormat = “”
 
Select Case Pj.CurrencySymbolPosition
 Case pjBefore
 CurrencyFormat = """" & Pj.CurrencySymbol & """"
 Case pjBeforeWithSpace
 CurrencyFormat = """" & Pj.CurrencySymbol & """" & " "
 End Select
 
CurrencyFormat = CurrencyFormat & "#,##0"
 
If ActiveProject.CurrencyDigits > 0 Then
 CurrencyFormat = CurrencyFormat & "."
 For i = 1 To Pj.CurrencyDigits
 CurrencyFormat = CurrencyFormat & "0"
 Next i
 End If
 
Select Case Pj.CurrencySymbolPosition
 Case pjAfter
 CurrencyFormat = CurrencyFormat & """" & Pj.CurrencySymbol & """"
 Case pjAfterWithSpace
 CurrencyFormat = CurrencyFormat & " " & """" & Pj.CurrencySymbol & """"
 End Select
 
SetCurrencyFormat = CurrencyFormat
 
End Function


Viewing all articles
Browse latest Browse all 5347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>