sangramkesharijena
New Member
Hi,
I am new to Excel VBA programming. Recorded the macro for pivot table but it is not working properly.
My data sheet consits of Current week (CW) 44,45,46 etc and Task code A,B,C,D etc. Want to know for Current week-44 how may task A,B,C completed then CW-45 how many task B,C,D completed then so on.... In pivot Table Report Filter filed column draging "Current week", Row Lable "Task code" and Values Field "Count of Task Code". The Task code of Row leble is not getting exuceted while runnig the macro but values filed working perfectly. Any body please help me to solve the problem.
Thank you in advance for your help and support.
CODE
Sub Pivottable()
'
' Pivottable Macro
'
'
ActiveWorkbook.Worksheets("Sheet2").PivotTables("PivotTable5").PivotCache. _
CreatePivotTable TableDestination:="Sheet4!R5C2", TableName:="PivotTable8" _
, DefaultVersion:=xlPivotTableVersion14
Sheets("Sheet4").Select
Cells(5, 2).Select
With ActiveSheet.PivotTables("PivotTable8").PivotFields("CW")
.Orientation = xlPageField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable8").PivotFields("Task Code")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable8").AddDataField ActiveSheet.PivotTables( _
"PivotTable8").PivotFields("Task Code"), "Count of Task Code", xlCount
End Sub
Regards,
sangram
I am new to Excel VBA programming. Recorded the macro for pivot table but it is not working properly.
My data sheet consits of Current week (CW) 44,45,46 etc and Task code A,B,C,D etc. Want to know for Current week-44 how may task A,B,C completed then CW-45 how many task B,C,D completed then so on.... In pivot Table Report Filter filed column draging "Current week", Row Lable "Task code" and Values Field "Count of Task Code". The Task code of Row leble is not getting exuceted while runnig the macro but values filed working perfectly. Any body please help me to solve the problem.
Thank you in advance for your help and support.
CODE
Sub Pivottable()
'
' Pivottable Macro
'
'
ActiveWorkbook.Worksheets("Sheet2").PivotTables("PivotTable5").PivotCache. _
CreatePivotTable TableDestination:="Sheet4!R5C2", TableName:="PivotTable8" _
, DefaultVersion:=xlPivotTableVersion14
Sheets("Sheet4").Select
Cells(5, 2).Select
With ActiveSheet.PivotTables("PivotTable8").PivotFields("CW")
.Orientation = xlPageField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable8").PivotFields("Task Code")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable8").AddDataField ActiveSheet.PivotTables( _
"PivotTable8").PivotFields("Task Code"), "Count of Task Code", xlCount
End Sub
Regards,
sangram