Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CRL CRL is offline
external usenet poster
 
Posts: 1
Default Error updating pivot table source data

Hi,

I'm trying to write a VB 6 app that updates the source
range for a set of pivot tables. Specifically, I'm using
the following code:

Set xlOutputSheet = xlOutputWorkbook.Sheets("MySheet")
Set xlPivot = xlOutputSheet.PivotTables _
("MyPivotTable")
Set xlPivotCache = xlPivot.PivotCache
RangeString = "MyOtherSheet!R2C1:R" & _
(Table_Dimension) & "C10"
With xlPivotCache
.SourceData = RangeString
.Refresh
End With

For most of the pivot tables, this works. However,
occasionally, for a reason I can't deduce I get the
following error:

"Application-defined or object-defined error"
at ".SourceData = RangeString". I'm pretty certain the
RangeString is correct.

Any insight would be helpful.

Thanks,

Craig

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Error updating pivot table source data

Try adding the following code to make debugging easier:

Set wsMyOtherSheet = Sheets("MyOtherSheet")
Set rngData = wsMyOtherSheet.Range("R2C1:R2C10").Resize(Table_Di mension)

then change to some variation of the following line (single step the
debugger and double-check that the string includes the worksheet name) :
.SourceData = rngData.Address

If the worksheet name has spaces in it, then I think quotes or brackets
around the worksheet name are required. The Resize method is an easier way
of extending the data area rather than trying to concantenate strings
together to define the range of the data.

When the error occurs, you should then be able to double-check what rngData
is set to. It might be that Table_Dimension happens to be wrong, or 0, or
something. I have seen this error myself in the past, but can't quite
remember the exact nature, except in the case where there is actually no
data for some reason. Also, make sure that you actually have 10 columns of
labels (R1C1 to R1C10), otherwise the pivot table methods will throw an
error because they can't resolve the fields.
--
Regards,
Bill


"CRL" wrote in message
...
Hi,

I'm trying to write a VB 6 app that updates the source
range for a set of pivot tables. Specifically, I'm using
the following code:

Set xlOutputSheet = xlOutputWorkbook.Sheets("MySheet")
Set xlPivot = xlOutputSheet.PivotTables _
("MyPivotTable")
Set xlPivotCache = xlPivot.PivotCache
RangeString = "MyOtherSheet!R2C1:R" & _
(Table_Dimension) & "C10"
With xlPivotCache
.SourceData = RangeString
.Refresh
End With

For most of the pivot tables, this works. However,
occasionally, for a reason I can't deduce I get the
following error:

"Application-defined or object-defined error"
at ".SourceData = RangeString". I'm pretty certain the
RangeString is correct.

Any insight would be helpful.

Thanks,

Craig



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
Error "invalid data source reference" for pivot table Manny Excel Worksheet Functions 6 April 5th 23 02:58 PM
Pivot Table "Data source reference is not valid" error cause? Bill Neurohr Excel Discussion (Misc queries) 1 March 11th 09 10:16 PM
updating pivot tables using dynamic data source dab4211 Excel Discussion (Misc queries) 3 July 24th 06 09:30 PM
Pivot Table data source "data source contains no visible tables" Jane Excel Worksheet Functions 0 September 29th 05 08:28 PM
Field Source Error for Pivot Table JM Excel Worksheet Functions 1 July 29th 05 02:08 AM


All times are GMT +1. The time now is 08:56 AM.

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

About Us

"It's about Microsoft Excel"