• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Run time error 1004 reference is not valid

annupojupradeep

New Member
HI Team,


This is A Pradeep Kumar from India, I like this site because I am learning new things about excel which helps me in my daily official worl. I am an employee in a private company.


At present I am working running a macro in MS 2003 version but while running same macro in 2007 version i am getting run time error 1004 refernce in not valid message;


my script is


ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _

"Data").CreatePivotTable TableDestination:="", TableName:= _

"PivotTable1", DefaultVersion:=xlPivotTableVersion10


Could please help on this problem


Regards,

Pradeep
 
Pradeep


Try recording a macro in 2007/2010 which does the same thing that this part of your VBA code is doing


Then look at the code and see what is different for this command
 
Hi Hui,


I have already record the only that pivot part in 2007 version and below is the script


ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _

"DataBase!R1C1:R5329C21", Version:=xlPivotTableVersion12).CreatePivotTable _

TableDestination:="", TableName:="PivotTable1", DefaultVersion:= _

xlPivotTableVersion12

ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)

ActiveSheet.Cells(3, 1).Select

With ActiveSheet.PivotTables("PivotTable1").PivotFields("CoCode")

.Orientation = xlRowField

.Position = 1

End With

ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _

"PivotTable1").PivotFields("CoCode"), "Count of CoCode", xlCount

End Sub


I found that there is xlPivotTableVersion12 but in 2003 it xlPivotTableVersion10


i chnanged the that 10 to 12 but still same problem.
 
Back
Top