Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel TableDestination As String?

I've recorded an Excel macro which successfully creates a new pivot
table on mySheet.xls. For example:

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,
SourceData:="YIS!R2C1:R15C26").CreatePivotTable
TableDestination:="[mySheet.xls] YIS!R18C1", TableName:=PivotTable15,
DefaultVersion:=xlPivotTableVersion10

I need to be able to dynamically change the TableDestination value
from mySheet.xls to a string variable as my macro will be creating
pivot tables across multiple workbooks.

I've tried turning this into one big string using Chr$(34) for the
double quotes but can't seem to get this working correctly. Any
suggestions are welcomed!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Excel TableDestination As String?

Try the following.

Dim strDestWB As String
Dim strSourceWB As String


'Edit the following 2 lines to match your workbook names.
'Note that the workbooks must be saved and must be open
'before the code will work.

strSourceWB = "Book1Source.xls"
strDestWB = "Book2pivot.xls"

Workbooks(strDestWB).PivotCaches.Add(SourceType:=x lDatabase, _
SourceData:="[" & strSourceWB & "]" & "YIS!R2C1:R15C26") _
..CreatePivotTable TableDestination:= _
"[" & strDestWB & "]" & "YIS!R18C1", _
TableName:=PivotTable15, _
DefaultVersion:=xlPivotTableVersion10
--
Regards,

OssieMac


"gstoa" wrote:

I've recorded an Excel macro which successfully creates a new pivot
table on mySheet.xls. For example:

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,
SourceData:="YIS!R2C1:R15C26").CreatePivotTable
TableDestination:="[mySheet.xls] YIS!R18C1", TableName:=PivotTable15,
DefaultVersion:=xlPivotTableVersion10

I need to be able to dynamically change the TableDestination value
from mySheet.xls to a string variable as my macro will be creating
pivot tables across multiple workbooks.

I've tried turning this into one big string using Chr$(34) for the
double quotes but can't seem to get this working correctly. Any
suggestions are welcomed!

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
Change 3 letter text string to a number string Pete Excel Discussion (Misc queries) 3 December 31st 07 07:47 PM
Replace Hyperlink Addresses Help 'Dim OldStr As String, NewStr As String Ron[_14_] Excel Programming 6 January 23rd 07 07:38 PM
Importing Long String - String Manipulation (INVRPT) (EDI EANCOM 96a) Brian Excel Programming 3 February 9th 06 03:38 PM
to search for a string and affect data if it finds the string? Shwaman Excel Worksheet Functions 1 January 11th 06 12:56 AM
Create a formula into a String then assign string to a cell Myrna Larson[_2_] Excel Programming 6 August 23rd 03 09:42 PM


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

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"