Amnicbra
05-31-2005, 12:19 PM
I am trying to add a table to my x number of sheets and the pivot table is names the sheet name but the following code is causeing this error ---
"Run-Time error: '1004'"
"Reference in not valid"
pTableName = "PivotTable-" & vNewSheet
Range("G1").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:="!E5") _
.CreatePivotTable TableDestination:=Range("G1"), TableName:=pTableName
ActiveSheet.PivotTables(pTableName).SmallGrid = False
With ActiveSheet.PivotTables(pTableName).PivotFields("Real Name")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables(pTableName).PivotFields("Real Name")
.Orientation = xlDataField
.Position = 1
End With
Application.CommandBars("PivotTable").Visible = False
Also Having problems passing the variables from module1 to module2 and form (code area):dunno
"Run-Time error: '1004'"
"Reference in not valid"
pTableName = "PivotTable-" & vNewSheet
Range("G1").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:="!E5") _
.CreatePivotTable TableDestination:=Range("G1"), TableName:=pTableName
ActiveSheet.PivotTables(pTableName).SmallGrid = False
With ActiveSheet.PivotTables(pTableName).PivotFields("Real Name")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables(pTableName).PivotFields("Real Name")
.Orientation = xlDataField
.Position = 1
End With
Application.CommandBars("PivotTable").Visible = False
Also Having problems passing the variables from module1 to module2 and form (code area):dunno