Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Pivot table Destination


Hi all,

I am trying to create a pivot table in a specific cell on a sheet. The
code I have is below. Basically I want to create pivot table so it
appears in the cell I have named as PTCell. PLEASE HELP as this does
not work

Private Sub MovPivot()
Dim PTCell As Range

'Pass heading to a String variable
'strField = Selection.Cells(1, 1).Text

'Name the list range
Sheets("Mobile").Activate
ActiveSheet.Range("A1").Select
ActiveCell.End(xlToRight).End(xlDown).Select
Range(ActiveCell, "A1").Select
Selection.Name = "Data"

Range("A1").Select

ActiveCell.End(xlDown).Offset(2, 0).Select
Set PTCell = ActiveCell

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"Data").CreatePivotTable TableDestination:= _
"'[DSG B&B Template.xls]Mobile'!PTCell",
TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion10


--
moglione1
------------------------------------------------------------------------
moglione1's Profile: http://www.excelforum.com/member.php...o&userid=26414
View this thread: http://www.excelforum.com/showthread...hreadid=515279

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Pivot table Destination


Does naybody know if this is possible


--
moglione1
------------------------------------------------------------------------
moglione1's Profile: http://www.excelforum.com/member.php...o&userid=26414
View this thread: http://www.excelforum.com/showthread...hreadid=515279

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Pivot table Destination

I'm guessing that PTCell is a cell in a different workbook.

If that's true, then take a look at VBA's help for .CreatePivotTable. You'll
see this line:

The destination range must be on a worksheet in the workbook that contains the
PivotCache object specified by expression.

=======
If that PTCell is in the same workbook, then:

Dim PTCell as range
.....

Set PTCell _
= activeworkbook.Worksheets("Mobile").Range("PTCell" )
.....

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"Data").CreatePivotTable TableDestination:=PTCell, _
TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion10

Looks like it would work.

moglione1 wrote:

Hi all,

I am trying to create a pivot table in a specific cell on a sheet. The
code I have is below. Basically I want to create pivot table so it
appears in the cell I have named as PTCell. PLEASE HELP as this does
not work

Private Sub MovPivot()
Dim PTCell As Range

'Pass heading to a String variable
'strField = Selection.Cells(1, 1).Text

'Name the list range
Sheets("Mobile").Activate
ActiveSheet.Range("A1").Select
ActiveCell.End(xlToRight).End(xlDown).Select
Range(ActiveCell, "A1").Select
Selection.Name = "Data"

Range("A1").Select

ActiveCell.End(xlDown).Offset(2, 0).Select
Set PTCell = ActiveCell

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"Data").CreatePivotTable TableDestination:= _
"'[DSG B&B Template.xls]Mobile'!PTCell",
TableName:="PivotTable1", _
DefaultVersion:=xlPivotTableVersion10

--
moglione1
------------------------------------------------------------------------
moglione1's Profile: http://www.excelforum.com/member.php...o&userid=26414
View this thread: http://www.excelforum.com/showthread...hreadid=515279


--

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
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
Refresh Pivot Table: Do you want to replace the destination cells pgchop Excel Programming 2 January 19th 06 12:31 PM
pivot table destination Douvid Excel Programming 1 December 13th 03 06:46 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 11:10 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"