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


Hi, I have a pivot table macro on a dynamic range of data with varying
number of rows and columns.
My code below isnt quite working, pretty sure its to do with:
SourceData:= "Original!cells(x,1),cells(1,y)")

Many Thks

Sub test()

x = Range("A50000").End(xlUp).Row
y = Range("IV1").End(xlToLeft).Column


Range("A1").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:
_
"Original!cells(x,1),cells(1,y)").CreatePivotT abl
TableDestination:="", TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3
1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="Cat4"
_
ColumnFields:="Account"

ActiveSheet.PivotTables("PivotTable1").PivotFields ("Amount").Orientatio
= _
xlDataField
ActiveWorkbook.ShowPivotTableFieldList = True
ActiveSheet.Name = "Check"
End Su

--
T De Villier
-----------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...fo&userid=2647
View this thread: http://www.excelforum.com/showthread.php?threadid=56428

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default Pivottable References

Change "Original!cells(x,1),cells(1,y)").
to this
"Original!" & cells(x,1).Address & "," cells(1,y).Address).

HTH

Die_Another_Day

T De Villiers wrote:
Hi, I have a pivot table macro on a dynamic range of data with varying
number of rows and columns.
My code below isnt quite working, pretty sure its to do with:
SourceData:= "Original!cells(x,1),cells(1,y)")

Many Thks

Sub test()

x = Range("A50000").End(xlUp).Row
y = Range("IV1").End(xlToLeft).Column


Range("A1").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:=
_
"Original!cells(x,1),cells(1,y)").CreatePivotT able
TableDestination:="", TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3,
1)
ActiveSheet.Cells(3, 1).Select
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="Cat4",
_
ColumnFields:="Account"

ActiveSheet.PivotTables("PivotTable1").PivotFields ("Amount").Orientation
= _
xlDataField
ActiveWorkbook.ShowPivotTableFieldList = True
ActiveSheet.Name = "Check"
End Sub


--
T De Villiers
------------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479
View this thread: http://www.excelforum.com/showthread...hreadid=564282


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
Help with converting a block of cells with Absolute and mixed references to relative references Vulcan Excel Worksheet Functions 3 December 13th 07 11:43 PM
Creating a PivotTable w/o selecting data in an existing PivotTable Damian Excel Discussion (Misc queries) 6 November 2nd 07 04:44 PM
How to rename references from range names to cell references Abbas Excel Discussion (Misc queries) 1 May 24th 06 06:18 PM
Pivottable references and values Geoff Excel Programming 0 April 10th 06 06:03 PM
PivotTable - PivotTable Field name is not valid - error! miker1999[_17_] Excel Programming 1 June 10th 04 10:30 AM


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