PC Review


Reply
Thread Tools Rate Thread

Creating PivotTable in Macro

 
 
=?Utf-8?B?Q09WIE1hcnNoYWxsVA==?=
Guest
Posts: n/a
 
      8th Oct 2007
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:=xlDatabase, SourceData:= _
"'Projects Detail & GL Accounts'!R1C1:R" & (endRow + 1) &
"C16").CreatePivotTable _
TableDestination:="", TableName:="PivotTable1", DefaultVersion:= _
xlPivotTableVersion10
 
Reply With Quote
 
 
 
 
Roger Govier
Guest
Posts: n/a
 
      9th Oct 2007
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" <(E-Mail Removed)> wrote in message
news:4365B981-B837-4133-939F-(E-Mail Removed)...
>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:=xlDatabase, SourceData:= _
> "'Projects Detail & GL Accounts'!R1C1:R" & (endRow + 1) &
> "C16").CreatePivotTable _
> TableDestination:="", TableName:="PivotTable1", DefaultVersion:= _
> xlPivotTableVersion10



 
Reply With Quote
 
Roger Govier
Guest
Posts: n/a
 
      9th Oct 2007
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:=xlDatabase, SourceData:= _
"'Projects Detail & GL Accounts'!R1C1:R" & (endRow + 1) &
"C16").CreatePivotTable _
TableDestination:="", TableName:="PivotTable1", DefaultVersion:= _
xlPivotTableVersion10

--
Regards
Roger Govier



"COV MarshallT" <(E-Mail Removed)> wrote in message
news:4365B981-B837-4133-939F-(E-Mail Removed)...
>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:=xlDatabase, SourceData:= _
> "'Projects Detail & GL Accounts'!R1C1:R" & (endRow + 1) &
> "C16").CreatePivotTable _
> TableDestination:="", TableName:="PivotTable1", DefaultVersion:= _
> xlPivotTableVersion10



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a PivotTable w/o selecting data in an existing PivotTable =?Utf-8?B?RGFtaWFu?= Microsoft Excel Misc 6 2nd Nov 2007 04:44 PM
Creating a PivotTable in VBA (Access97) =?Utf-8?B?TUN5bg==?= Microsoft Access VBA Modules 0 21st Jul 2005 04:18 PM
Creating a PivotTable with VBA =?Utf-8?B?RW5yaWNvIENhbXBpZG9nbGlv?= Microsoft Excel Programming 2 27th Jun 2005 12:09 PM
Type Mismatch when creating a pivottable macro MikeC Microsoft Excel Programming 1 7th Sep 2004 09:35 AM
Creating a database and PivotTable with a Macro =?Utf-8?B?c2FsZXMyNg==?= Microsoft Excel Programming 2 19th May 2004 05:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:26 AM.