1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| Private Sub CommandButton1_Click()
Dim ws As Worksheet
Dim StartingHour As Integer
Dim EndingHour As Integer
Dim IntervalTime As String
Dim DayEvent As Integer
Dim ResultPivot As Range
Dim TimeSpent As Integer
Dim pvt As PivotTable
DayEvent = 1
StartingHour = 11
EndingHour = 14
IntervalTime = Format(StartingHour, "00") & "00/" & Format(EndingHour, "00") & "00"
Set ws = Worksheets("Pivot")
Set pvt = ws.PivotTables(1)
'ws.EnablePivotTable = True
Set ResultPivot = pvt.GetPivotData("Time spent on the release", "Frequency", DayEvent, "Time of release", IntervalTime)
TimeSpent = ResultPivot.Value
MsgBox TimeSpent
End Sub |
Partager