Hi I am writing this code and getting stuck at line
oChart2.SetSourceData Source:=PT2.TableRange1
Dim data1, data2 As PivotCache
Dim PT1, PT2, PT3, PT4, PT5 As PivotTable
For Each ws In Worksheets
If ws.Name = "Bidding" Then
Application.DisplayAlerts = False
Worksheets("Bidding").Delete
Application.DisplayAlerts = True
End If
Next
'Worksheet.Add
Worksheets.Add before:=Sheets("BOE")
ActiveSheet.Name = "Bidding"
Sheets("CR").Select
Dim A, B As Integer
A = Range("A1", Range("A1").End(xlToRight)).COUNT
B = Range("A1", Range("A1").End(xlDown)).COUNT
Set data2 = ActiveWorkbook.PivotCaches.Create(xlDatabase, Range("A1", Cells(B, A)).Address(, , xlR1C1))
'====================================================
'==== TABLE 1 = Sole Ethernet========================
'====================================================
Set PT1 = data2.CreatePivotTable(Worksheets("Bidding").Range("B3"))
With PT1
With .PivotFields("New Access Tech")
.Orientation = xlColumnField
.Position = 1
End With
'PT1.PivotFields("New Access Tech").CurrentColumn = "Ethernet"
With PT1
With .PivotFields("Multiple Bids")
.Orientation = xlPageField
.Position = 1
End With
PT1.PivotFields("Multiple Bids").CurrentPage = "Sole"
With .PivotFields("CR Carrier")
.Orientation = xlRowField
.Position = 1
End With
'With PT1.PivotFields("CR Quotes Z-NZ")
'.Orientation = xlDataField
'.Function = xlSum
'.Position = 1
'.Caption = "Bids"
'End With
With PT1.PivotFields("CR=WINNER")
.Orientation = xlDataField
.Function = xlSum
.Position = 1
.Caption = "Wins"
End With
With PT1
.RowGrand = False
.MergeLabels = True
.InGridDropZones = True
.RowAxisLayout xlTabularRow
.SmallGrid = True
.ShowTableStyleColumnHeaders = True
.LayoutRowDefault = xlTabularRow
End With
End With
End With
Dim oChart1 As chart
Set oChart1 = PT1.Parent.Shapes.AddChart(XlChartType:=xlstackedBar).chart
oChart1.SetSourceData Source:=PT1.TableRange1
With oChart1
.HasTitle = True
.ChartTitle.Text = "Sole Ethernet Wins"
.ShowAllFieldButtons = False
End With
With oChart1.PlotArea.FORMAT.Fill
.ForeColor.RGB = RGB(224, 224, 224)
'.Transparency = 0
End With
With oChart1.ChartArea.FORMAT.Fill
.ForeColor.RGB = RGB(224, 224, 224)
'.Transparency = 0
End With
With oChart1.Axes(xlValue)
.DisplayUnit = xlThousands
End With
'====================================================
'==== TABLE 2 = Sole LL==============================
'====================================================
Set PT2 = data2.CreatePivotTable(Worksheets("Bidding").Range("B23"))
With PT2
With .PivotFields("New Access Tech")
.Orientation = xlColumnField
.Position = 1
.PivotItems("LL").Visible = False
End With
'PT1.PivotFields("New Access Tech").CurrentColumn = "Ethernet"
With PT2
With .PivotFields("Multiple Bids")
.Orientation = xlPageField
.Position = 1
End With
PT2.PivotFields("Multiple Bids").CurrentPage = "Sole"
With .PivotFields("CR Carrier")
.Orientation = xlRowField
.Position = 1
End With
'With PT1.PivotFields("CR Quotes Z-NZ")
'.Orientation = xlDataField
'.Function = xlSum
'.Position = 1
'.Caption = "Bids"
'End With
With PT2.PivotFields("CR=WINNER")
.Orientation = xlDataField
.Function = xlSum
.Position = 1
.Caption = "Wins"
End With
With PT2
.RowGrand = False
.MergeLabels = True
.InGridDropZones = True
.RowAxisLayout xlTabularRow
.SmallGrid = True
.ShowTableStyleColumnHeaders = True
.LayoutRowDefault = xlTabularRow
End With
End With
End With
Dim oChart2 As chart
Set oChart2 = PT2.Parent.Shapes.AddChart(XlChartType:=xlBar).chart
oChart2.SetSourceData Source:=PT2.TableRange1
With oChart2
.HasTitle = True
.ChartTitle.Text = "Sole Ethernet Wins"
.ShowAllFieldButtons = False
End With
With oChart2.PlotArea.FORMAT.Fill
.ForeColor.RGB = RGB(224, 224, 224)
'.Transparency = 0
End With
With oChart2.ChartArea.FORMAT.Fill
.ForeColor.RGB = RGB(224, 224, 224)
'.Transparency = 0
End With
With oChart2.Axes(xlValue)
.DisplayUnit = xlThousands
End With
End Sub
oChart2.SetSourceData Source:=PT2.TableRange1
Dim data1, data2 As PivotCache
Dim PT1, PT2, PT3, PT4, PT5 As PivotTable
For Each ws In Worksheets
If ws.Name = "Bidding" Then
Application.DisplayAlerts = False
Worksheets("Bidding").Delete
Application.DisplayAlerts = True
End If
Next
'Worksheet.Add
Worksheets.Add before:=Sheets("BOE")
ActiveSheet.Name = "Bidding"
Sheets("CR").Select
Dim A, B As Integer
A = Range("A1", Range("A1").End(xlToRight)).COUNT
B = Range("A1", Range("A1").End(xlDown)).COUNT
Set data2 = ActiveWorkbook.PivotCaches.Create(xlDatabase, Range("A1", Cells(B, A)).Address(, , xlR1C1))
'====================================================
'==== TABLE 1 = Sole Ethernet========================
'====================================================
Set PT1 = data2.CreatePivotTable(Worksheets("Bidding").Range("B3"))
With PT1
With .PivotFields("New Access Tech")
.Orientation = xlColumnField
.Position = 1
End With
'PT1.PivotFields("New Access Tech").CurrentColumn = "Ethernet"
With PT1
With .PivotFields("Multiple Bids")
.Orientation = xlPageField
.Position = 1
End With
PT1.PivotFields("Multiple Bids").CurrentPage = "Sole"
With .PivotFields("CR Carrier")
.Orientation = xlRowField
.Position = 1
End With
'With PT1.PivotFields("CR Quotes Z-NZ")
'.Orientation = xlDataField
'.Function = xlSum
'.Position = 1
'.Caption = "Bids"
'End With
With PT1.PivotFields("CR=WINNER")
.Orientation = xlDataField
.Function = xlSum
.Position = 1
.Caption = "Wins"
End With
With PT1
.RowGrand = False
.MergeLabels = True
.InGridDropZones = True
.RowAxisLayout xlTabularRow
.SmallGrid = True
.ShowTableStyleColumnHeaders = True
.LayoutRowDefault = xlTabularRow
End With
End With
End With
Dim oChart1 As chart
Set oChart1 = PT1.Parent.Shapes.AddChart(XlChartType:=xlstackedBar).chart
oChart1.SetSourceData Source:=PT1.TableRange1
With oChart1
.HasTitle = True
.ChartTitle.Text = "Sole Ethernet Wins"
.ShowAllFieldButtons = False
End With
With oChart1.PlotArea.FORMAT.Fill
.ForeColor.RGB = RGB(224, 224, 224)
'.Transparency = 0
End With
With oChart1.ChartArea.FORMAT.Fill
.ForeColor.RGB = RGB(224, 224, 224)
'.Transparency = 0
End With
With oChart1.Axes(xlValue)
.DisplayUnit = xlThousands
End With
'====================================================
'==== TABLE 2 = Sole LL==============================
'====================================================
Set PT2 = data2.CreatePivotTable(Worksheets("Bidding").Range("B23"))
With PT2
With .PivotFields("New Access Tech")
.Orientation = xlColumnField
.Position = 1
.PivotItems("LL").Visible = False
End With
'PT1.PivotFields("New Access Tech").CurrentColumn = "Ethernet"
With PT2
With .PivotFields("Multiple Bids")
.Orientation = xlPageField
.Position = 1
End With
PT2.PivotFields("Multiple Bids").CurrentPage = "Sole"
With .PivotFields("CR Carrier")
.Orientation = xlRowField
.Position = 1
End With
'With PT1.PivotFields("CR Quotes Z-NZ")
'.Orientation = xlDataField
'.Function = xlSum
'.Position = 1
'.Caption = "Bids"
'End With
With PT2.PivotFields("CR=WINNER")
.Orientation = xlDataField
.Function = xlSum
.Position = 1
.Caption = "Wins"
End With
With PT2
.RowGrand = False
.MergeLabels = True
.InGridDropZones = True
.RowAxisLayout xlTabularRow
.SmallGrid = True
.ShowTableStyleColumnHeaders = True
.LayoutRowDefault = xlTabularRow
End With
End With
End With
Dim oChart2 As chart
Set oChart2 = PT2.Parent.Shapes.AddChart(XlChartType:=xlBar).chart
oChart2.SetSourceData Source:=PT2.TableRange1
With oChart2
.HasTitle = True
.ChartTitle.Text = "Sole Ethernet Wins"
.ShowAllFieldButtons = False
End With
With oChart2.PlotArea.FORMAT.Fill
.ForeColor.RGB = RGB(224, 224, 224)
'.Transparency = 0
End With
With oChart2.ChartArea.FORMAT.Fill
.ForeColor.RGB = RGB(224, 224, 224)
'.Transparency = 0
End With
With oChart2.Axes(xlValue)
.DisplayUnit = xlThousands
End With
End Sub