Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Creating PivotTable in Macro

I have recorded a macro to create a PivotTable, and I can get it to run
successfully on my PC. But when a user on another PC tries it, they get
"Run-time error '1004': Application-defined or object-defined error. When I
go to debug, the entire portion of the below code beginning with
"ActiveWorkbook" is highlighted as the source of the problem. Does anyone
have any idea as to why this might happen? Thanks for your help!
Range("A1").Select
Dim endRow As Long
endRow = Cells(Rows.Count, 1).End(xlUp).Row
Range("K2").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"'Projects Detail & GL Accounts'!R1C1:R" & (endRow + 1) &
"C16").CreatePivotTable _
TableDestination:="", TableName:="PivotTable1", DefaultVersion:= _
xlPivotTableVersion10
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,480
Default Creating PivotTable in Macro

Hi

Error 1004 could be returned, if the destination sheet already had a Pivot
Table with the same name already present.
It sounds as though the other user has the existing PT sheet active, when
they are trying to run the macro.
--
Regards
Roger Govier



"COV MarshallT" wrote in message
...
I have recorded a macro to create a PivotTable, and I can get it to run
successfully on my PC. But when a user on another PC tries it, they get
"Run-time error '1004': Application-defined or object-defined error. When
I
go to debug, the entire portion of the below code beginning with
"ActiveWorkbook" is highlighted as the source of the problem. Does anyone
have any idea as to why this might happen? Thanks for your help!
Range("A1").Select
Dim endRow As Long
endRow = Cells(Rows.Count, 1).End(xlUp).Row
Range("K2").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"'Projects Detail & GL Accounts'!R1C1:R" & (endRow + 1) &
"C16").CreatePivotTable _
TableDestination:="", TableName:="PivotTable1", DefaultVersion:= _
xlPivotTableVersion10



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,480
Default Creating PivotTable in Macro

Hi

Hit the send button too soon
I meant to add, you could ensure this didn't happen if you specifically
selected the source data sheet before starting

Sheets("Projects Detail & GL Accounts").Range("A1").Select
Dim endRow As Long
endRow = Cells(Rows.Count, 1).End(xlUp).Row
Range("K2").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"'Projects Detail & GL Accounts'!R1C1:R" & (endRow + 1) &
"C16").CreatePivotTable _
TableDestination:="", TableName:="PivotTable1", DefaultVersion:= _
xlPivotTableVersion10

--
Regards
Roger Govier



"COV MarshallT" wrote in message
...
I have recorded a macro to create a PivotTable, and I can get it to run
successfully on my PC. But when a user on another PC tries it, they get
"Run-time error '1004': Application-defined or object-defined error. When
I
go to debug, the entire portion of the below code beginning with
"ActiveWorkbook" is highlighted as the source of the problem. Does anyone
have any idea as to why this might happen? Thanks for your help!
Range("A1").Select
Dim endRow As Long
endRow = Cells(Rows.Count, 1).End(xlUp).Row
Range("K2").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"'Projects Detail & GL Accounts'!R1C1:R" & (endRow + 1) &
"C16").CreatePivotTable _
TableDestination:="", TableName:="PivotTable1", DefaultVersion:= _
xlPivotTableVersion10



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a PivotTable w/o selecting data in an existing PivotTable Damian Excel Discussion (Misc queries) 6 November 2nd 07 04:44 PM
Creating a PivotTable in VBA Peter Aitken Excel Programming 0 August 23rd 05 03:16 PM
Creating a PivotTable with VBA Enrico Campidoglio Excel Programming 2 June 27th 05 12:09 PM
Type Mismatch when creating a pivottable macro MikeC[_3_] Excel Programming 1 September 7th 04 09:35 AM
Creating a database and PivotTable with a Macro sales26 Excel Programming 2 May 19th 04 05:05 PM


All times are GMT +1. The time now is 06:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"