Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default incorporate string variable into VB code


This is a follow-up to an earlier post. I have provided a few more
details about what I need to do.

I need to find out how to incorporate a string variable (i.e. the
active worksheet's tab name; assume: "active_wksht") directly into my
VB coding. For example, the following code begins to create a Pivot
Table. It references a specific worksheet, i.e. the active worksheet
("9-24-05").

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"'9-24-05!R3C1:R200C5").CreatePivotTable TableDestination:= _
"'[Tally.xls]9-24-05'!R3C8", TableName:="PivotTable1", DefaultVersion:=
_
xlPivotTableVersion10


Specifically, I'd like to find out how to incorporate the string
variable into the code, so that it reads, in part, as follows:

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"*active_wksht*!R3C1:R200C5").CreatePivotTable TableDestination:= _
"'[Tally.xls]'*active_wksht*!R3C8", TableName:="PivotTable1",
DefaultVersion:= _
xlPivotTableVersion10


This will cause the code to base the pivot table on the data in the
active worksheet without my having to manually edit the code to refer
to the active worksheet. I'd also need some help with the placement
(where needed) of double quotes, apostrophes, etc. to handle the
string, since apostrophes are needed around the worksheet name in the
code.


--
itsthebike
------------------------------------------------------------------------
itsthebike's Profile: http://www.excelforum.com/member.php...o&userid=27425
View this thread: http://www.excelforum.com/showthread...hreadid=469845

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default incorporate string variable into VB code



You could use ActiveSheet.name and ActiveWorkbook.name.

The syntax would be something like
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:=
Activesheet.name & "!R3C1:R200C5"



"itsthebike" wrote
in message ...

This is a follow-up to an earlier post. I have provided a few more
details about what I need to do.

I need to find out how to incorporate a string variable (i.e. the
active worksheet's tab name; assume: "active_wksht") directly into my
VB coding. For example, the following code begins to create a Pivot
Table. It references a specific worksheet, i.e. the active worksheet
("9-24-05").

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"'9-24-05!R3C1:R200C5").CreatePivotTable TableDestination:= _
"'[Tally.xls]9-24-05'!R3C8", TableName:="PivotTable1", DefaultVersion:=
_
xlPivotTableVersion10


Specifically, I'd like to find out how to incorporate the string
variable into the code, so that it reads, in part, as follows:

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"*active_wksht*!R3C1:R200C5").CreatePivotTable TableDestination:= _
"'[Tally.xls]'*active_wksht*!R3C8", TableName:="PivotTable1",
DefaultVersion:= _
xlPivotTableVersion10


This will cause the code to base the pivot table on the data in the
active worksheet without my having to manually edit the code to refer
to the active worksheet. I'd also need some help with the placement
(where needed) of double quotes, apostrophes, etc. to handle the
string, since apostrophes are needed around the worksheet name in the
code.


--
itsthebike
------------------------------------------------------------------------
itsthebike's Profile:

http://www.excelforum.com/member.php...o&userid=27425
View this thread: http://www.excelforum.com/showthread...hreadid=469845



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
incorporate the remove #DIV/0! code into another formula to get bl Morgan New Users to Excel 5 October 29th 09 04:48 AM
incorporate variable into VB code itsthebike Excel Programming 2 September 21st 05 03:32 PM
setting a range variable equal to the value of a string variable Pilgrim Excel Programming 2 July 1st 04 11:32 PM
How do I convert an integer variable to a string variable? dumbass Excel Programming 2 May 21st 04 07:34 PM
Join string with variable name to get variable value Dianne Excel Programming 6 February 12th 04 04:24 AM


All times are GMT +1. The time now is 09:16 PM.

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"