#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Pivot Table

Can I write a macro for a pivot table defining the range as

Range("A3:K3", Selection.End(xlDown)).Select

I'm trying with

Dim rng As Range
Range("A3:K3", Selection.End(xlDown)).Select

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"rng").CreatePivotTable TableDestination:= _
"'[Combined Filtered.xls]Pivot'!R5C1",
TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion10
And it tells me 'Nooooooooooo'.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Pivot Table

You could use the current region of cell A3. For example:

'=========================
Dim ws As Worksheet
Dim rng As Range
Set ws = Sheets("Sheet1")
Set rng = ws.Range("A3").CurrentRegion

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, _
SourceData:=ws.Name & "!" & rng.Address) _
.CreatePivotTable TableDestination:="", _
TableName:="PivotTable1"
'======================

solomon_monkey wrote:
Can I write a macro for a pivot table defining the range as

Range("A3:K3", Selection.End(xlDown)).Select

I'm trying with

Dim rng As Range
Range("A3:K3", Selection.End(xlDown)).Select

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"rng").CreatePivotTable TableDestination:= _
"'[Combined Filtered.xls]Pivot'!R5C1",
TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion10
And it tells me 'Nooooooooooo'.



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

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
how to create pivot table from existing pivot table in excel 2007 Udayraj Dhulekar Excel Discussion (Misc queries) 2 July 8th 13 08:22 PM
Pivot Table and Pivot Table dates are not in correct order ls Charts and Charting in Excel 3 July 14th 09 04:02 PM
Filter lines with Pivot table and non pivot table columns Grover Charts and Charting in Excel 4 September 28th 07 03:16 AM
Filter lines containing pivot table and non pivot table data Grover Excel Worksheet Functions 0 September 24th 07 07:20 PM
Help required with setting up a pivot table with the source on sheet1 to have the pivot table created on sheet called "report" Diana[_5_] Excel Programming 0 August 21st 03 10:19 PM


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