Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Create pivot table with VB

You can use the current region of the first cell on Sheet1, e.g.:

Dim rngData As Range
Set rngData = Worksheets("Sheet1").Range("A1").CurrentRegion

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, _
SourceData:=rngData).CreatePivotTable TableDestination:="", _
TableName:="PivotTable1"


JT wrote:
I have a master file that contains the data for every cost center. I need to
create a macro that will split the data into separate files for each cost
center. That hasn't been a problem and I have that working fine. All of the
data is being pasted on Sheet 2

What I need to do is create a pivot table on Sheet 1 with the data on Sheet
2. The rows of data will vary on Sheet 2 depending on the cost center. One
sheet may have 125 rows while another may have 550.

I'm splitting the data within a loop and want to create the pivot table each
time I copy and paste the data for each cost center.

I'm guessing I will have to create a range on each sheet 2 to refer to the
data in the pivot table code. I think I can do that.

(1) Can I use the same range name for each pivot table? And how do I delete
the range name after I create the pivot table

(2) How do I refer to the data range within the pivot table code?

Thanks for the help.........



--
Debra Dalgleish
Contextures
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
How do I create multiple pivot charts from one pivot table? Rudy Charts and Charting in Excel 1 March 17th 06 10:01 PM
pivot table: create worksheetsheet using pivot table Pivot Tables and New Worksheets Excel Discussion (Misc queries) 1 June 1st 05 10:01 PM
How do I create a pivot table if the pivot table icon or menu ite. Lynn@WS Charts and Charting in Excel 1 December 16th 04 02:36 AM
create pivot table linked to another pivot? possible? scottwilsonx[_23_] Excel Programming 1 August 12th 04 08:54 AM


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