Johnny Firefly
New Member
- Joined
- Aug 19, 2010
- Messages
- 3
Help!!! My first post on the forum. Have been tearing my hair out all afternoon trying to write this macro. My code is as follows:
Sub Macro1()
'Define where Pivot Table will be located
Range("A4").Select
Selection.End(xlDown).Select
ActiveCell.Offset(3, 0).Activate
Dim PivotStart
PivotStart = ActiveCell.Address
'Define Pivot Source Data
ActiveSheet.Range("a4").CurrentRegion.Select
Dim PivotData As Range
Set PivotData = Selection
'Create Pivot Cache
Dim PC As PivotCache
PC = ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=PivotData)
'Create PivotTable
Dim PT As PivotTable
PT = PC.CreatePivotTable(PivotStart)
End Sub
The code highlighted in orange causes the following error:
I'm getting the following error:
Run-Time error '438':
Object doesn't support this property or method
Any guidance would be greatly appreciated
Sub Macro1()
'Define where Pivot Table will be located
Range("A4").Select
Selection.End(xlDown).Select
ActiveCell.Offset(3, 0).Activate
Dim PivotStart
PivotStart = ActiveCell.Address
'Define Pivot Source Data
ActiveSheet.Range("a4").CurrentRegion.Select
Dim PivotData As Range
Set PivotData = Selection
'Create Pivot Cache
Dim PC As PivotCache
PC = ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=PivotData)
'Create PivotTable
Dim PT As PivotTable
PT = PC.CreatePivotTable(PivotStart)
End Sub
The code highlighted in orange causes the following error:
I'm getting the following error:
Run-Time error '438':
Object doesn't support this property or method
Any guidance would be greatly appreciated