Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Replace worksheet name with a variable

I want to use a worksheetname variable rather than the
hardcoded
worksheetname name, while creating a pivot table...

Please See the code below:

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,
SourceData:= _
"Raw_Data!R1C1:R884C59").CreatePivotTable
TableDestination:="",
TableName:= _
"PivotTable5", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard
TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveWorkbook.ShowPivotTableFieldList = True


Instead of raw_data I want to use RAWDATANAME variable....
How to replace
it?

Thanks in advance
monika

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Replace worksheet name with a variable

change

"Raw_Data!R1C1:R884C59").CreatePivotTable

to

RAWDATANAME = "raw_data"
RAWDATANAME & "!R1C1:R884C59").CreatePivotTable


---
Message posted from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Replace worksheet name with a variable

Dim wks as worksheet
Dim Rng as range

set wks = worksheets("raw_data")
with wks
set rng = .range("a1",.cells(884,59))
end with

.....sourcedata:=rng.address(external:=true), ...



monika wrote:

I want to use a worksheetname variable rather than the
hardcoded
worksheetname name, while creating a pivot table...

Please See the code below:

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,
SourceData:= _
"Raw_Data!R1C1:R884C59").CreatePivotTable
TableDestination:="",
TableName:= _
"PivotTable5", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard
TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveWorkbook.ShowPivotTableFieldList = True

Instead of raw_data I want to use RAWDATANAME variable....
How to replace
it?

Thanks in advance
monika


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Replace worksheet name with a variable

hi..

i found & solution quite simple....i just implemented and its working
nicely.

Thanks a lot..

Monika
"Dave Peterson" wrote in message
...
Dim wks as worksheet
Dim Rng as range

set wks = worksheets("raw_data")
with wks
set rng = .range("a1",.cells(884,59))
end with

....sourcedata:=rng.address(external:=true), ...



monika wrote:

I want to use a worksheetname variable rather than the
hardcoded
worksheetname name, while creating a pivot table...

Please See the code below:

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,
SourceData:= _
"Raw_Data!R1C1:R884C59").CreatePivotTable
TableDestination:="",
TableName:= _
"PivotTable5", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard
TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
ActiveWorkbook.ShowPivotTableFieldList = True

Instead of raw_data I want to use RAWDATANAME variable....
How to replace
it?

Thanks in advance
monika


--

Dave Peterson



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
Replace a fixed number with a variable via popup Colin Hayes Excel Worksheet Functions 3 August 16th 11 08:42 PM
Need to replace one dynamic variable with another dynamic variable djreason Excel Worksheet Functions 8 September 11th 09 01:57 AM
Looking up a variable in one worksheet and copying information from another column to another worksheet?? Brad Torken Excel Discussion (Misc queries) 2 December 10th 06 06:02 AM
3 variable find and replace ncspndoc Excel Discussion (Misc queries) 4 June 30th 06 09:07 PM
Replace variable row number in formulas Ldub Excel Discussion (Misc queries) 0 November 3rd 05 10:25 PM


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