Recorded Macro need to be customized

sur

Board Regular
Joined
Jul 4, 2011
Messages
178
Hello,

I have a recorded a macro for a report,

I need to customize the recorded macro

please find the below

Sub DQAdjustments()
'
' DQAdjustments Macro
'
'
Sheets("DATA").Select
Cells.Select
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"DATA!R1C1:R1048576C29", Version:=xlPivotTableVersion12).CreatePivotTable _
TableDestination:="Sheet3!R3C1", TableName:="PivotTable1", DefaultVersion _
:=xlPivotTableVersion12
Sheets("Sheet3").Select
Cells(3, 1).Select
ActiveWorkbook.ShowPivotTableFieldList = True
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Quarter")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("SO2")
.Orientation = xlRowField
.Position = 2
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("PG")
.Orientation = xlRowField
.Position = 3
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields( _
"HPS_Shpt Adjustments KUSD")
.Orientation = xlRowField
.Position = 4
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields( _
"HPS_Sellout Adjustments KUSD")
.Orientation = xlRowField
.Position = 5
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Quarter")
.Orientation = xlPageField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("HPS_Shpt Adjustments KUSD"), _
"Count of HPS_Shpt Adjustments KUSD", xlCount
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("HPS_Sellout Adjustments KUSD"), _
"Count of HPS_Sellout Adjustments KUSD", xlCount
With ActiveSheet.PivotTables("PivotTable1").PivotFields( _
"Count of HPS_Shpt Adjustments KUSD")
.Caption = "Sum of HPS_Shpt Adjustments KUSD"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields( _
"Count of HPS_Sellout Adjustments KUSD")
.Caption = "Sum of HPS_Sellout Adjustments KUSD"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("SO2")
.Orientation = xlRowField
.Position = 2
End With
ActiveSheet.PivotTables("PivotTable1").PivotFields("Quarter").ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields("Quarter").CurrentPage = _
"(All)"
With ActiveSheet.PivotTables("PivotTable1").PivotFields("PG")
.PivotItems("BCS").Visible = False
.PivotItems("#N/A").Visible = False
.PivotItems("(blank)").Visible = False
End With
Range("G34").Select
Sheets("Sheet3").Select
Sheets("Sheet3").Name = "TS"
Range("B40").Select
Sheets("DATA").Select
Sheets.Add
ActiveWorkbook.Worksheets("TS").PivotTables("PivotTable1").PivotCache. _
CreatePivotTable TableDestination:="Sheet4!R3C1", TableName:="PivotTable2" _
, DefaultVersion:=xlPivotTableVersion12
Sheets("Sheet4").Select
Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable2").PivotFields("Quarter")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable2").PivotFields("SO2")
.Orientation = xlRowField
.Position = 2
End With
With ActiveSheet.PivotTables("PivotTable2").PivotFields("PG")
.Orientation = xlRowField
.Position = 3
End With
With ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"BCS_Shpt Adjustments KUSD")
.Orientation = xlRowField
.Position = 4
End With
With ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"BCS_Sellout Adjustments KUSD")
.Orientation = xlRowField
.Position = 5
End With
With ActiveSheet.PivotTables("PivotTable2").PivotFields("Quarter")
.Orientation = xlPageField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
"PivotTable2").PivotFields("BCS_Shpt Adjustments KUSD"), _
"Count of BCS_Shpt Adjustments KUSD", xlCount
ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
"PivotTable2").PivotFields("BCS_Sellout Adjustments KUSD"), _
"Count of BCS_Sellout Adjustments KUSD", xlCount
With ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"Count of BCS_Shpt Adjustments KUSD")
.Caption = "Sum of BCS_Shpt Adjustments KUSD"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"Count of BCS_Sellout Adjustments KUSD")
.Caption = "Sum of BCS_Sellout Adjustments KUSD"
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable2").PivotFields("SO2")
.Orientation = xlRowField
.Position = 2
End With
With ActiveSheet.PivotTables("PivotTable2").PivotFields("PG")
.PivotItems("TS Care Pack (ESSN, IPG Comm)").Visible = False
.PivotItems("#N/A").Visible = False
.PivotItems("(blank)").Visible = False
End With
Sheets("Sheet4").Select
Sheets("Sheet4").Name = "BCS"
Range("C29").Select
ActiveWindow.SmallScroll Down:=-21
End Sub
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Welcome to the board.

In what way do you want this code customised? What do you need it to do that it doesn't do already?

Can I make a suggestion? You will tend to get more responses if you make it easier for people to read your code. This can be achieved by posting it between CODE tags - the # icon in the advanced editor toolbar. This will preserve indenting and use a fixed-width font, both of which make code easier to read.
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,909
Members
452,949
Latest member
beartooth91

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