Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default run-time error '9': Subscript out of range


Can anyone tell me why i get this error?

Sub ChangePivotCache()
'change pivot cache for all pivot tables in workbook
Dim pt As PivotTable
Dim wks As Worksheet

For Each wks In ActiveWorkbook.Worksheets
For Each pt In wks.PivotTables
pt.CacheIndex = Sheets("Pivot").PivotTables(1).CacheIndex
Next pt
Next wks

End Sub

PLEASE HELP!!


--
jerredjohnson
------------------------------------------------------------------------
jerredjohnson's Profile: http://www.excelforum.com/member.php...o&userid=32236
View this thread: http://www.excelforum.com/showthread...hreadid=520228

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default run-time error '9': Subscript out of range

What line is giving you the error? Most likely it is
pt.CacheIndex = Sheets("Pivot").PivotTables(1).CacheIndex

Are you sure you have a sheet call "Pivot" and are you sure that
there is at least one pivot table on it?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"jerredjohnson"

wrote in message
news:jerredjohnson.24d6xn_1141844102.6615@excelfor um-nospam.com...

Can anyone tell me why i get this error?

Sub ChangePivotCache()
'change pivot cache for all pivot tables in workbook
Dim pt As PivotTable
Dim wks As Worksheet

For Each wks In ActiveWorkbook.Worksheets
For Each pt In wks.PivotTables
pt.CacheIndex = Sheets("Pivot").PivotTables(1).CacheIndex
Next pt
Next wks

End Sub

PLEASE HELP!!


--
jerredjohnson
------------------------------------------------------------------------
jerredjohnson's Profile:
http://www.excelforum.com/member.php...o&userid=32236
View this thread:
http://www.excelforum.com/showthread...hreadid=520228



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
run-time error '9': subscript out of range [email protected] uk Excel Discussion (Misc queries) 4 December 8th 09 10:27 PM
Run-time error 9 (Subscript out of range) Lizz45ie[_3_] Excel Programming 3 October 26th 05 11:38 PM
run-time error '9': Subscript out of range AccessHelp Excel Programming 1 September 30th 05 05:10 PM
Run time error 9 : Subscript out of range JAtz_DA_WAY Excel Discussion (Misc queries) 6 August 29th 05 08:26 PM
Run time error 9 (subscript out of range) Nathaniel Tigere Excel Programming 2 August 5th 03 11:12 AM


All times are GMT +1. The time now is 08:26 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"