Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Excel Run-Time Error 1004 - HELP!!!

Status
Not open for further replies.

dmoonme

MIS
Jul 21, 2004
33
0
0
US
Hello, I am new to VBA and I appreciated your help. I am creating a PIVOT table to parse a text file but I get this error message "Run-Time Error 1004 If you creating a PivotTable type a cell reference or select a..."

Here's the code that causing the problem:

Sheets.Add
ActiveSheet.Name = "shares_aggregate"
coordinate = "R1C1:R" & rowdata & "C" & coldata
Worksheets(DataSheet).Activate
ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:= _
coordinate, TableDestination:="shares_aggregate!R1C1", _
TableName:="shares"
ActiveSheet.PivotTables("shares").AddFields RowFields:=Array( _
"Transaction Purpose", "Transaction Date")
With ActiveSheet.PivotTables("shares").PivotFields("Number of Shares")
.Orientation = xlDataField
.Name = "Sum of Number of Shares"
.Function = xlSum
End With
Columns("A:E").EntireColumn.AutoFit
Cells(1, 1).Select
 
Hiya,

I think this is because the AddFields method applies to a PivotTable object rather than the PivotTables collection as you have here

regards K :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top