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

Hi,

I am relatively new to writing code and in most cases
record a macro which I then manipulate to meet my needs.
So the question I am about to ask may sound very simple to
most of you....!

I have macro that basically collects data from an external
data source. The query has a few parameter queries in it
which allows the user to selet the criteria they want, so
changing the size of the data source each time. The macro
then uses the data to create a pivot table.

The problem I am having is the pivot table uses a hard
coded value for the datasource. As the records in the
datasource can change depending on criteria, the pivot
table can be correct. How can I ensure the datasource can
be dynamically calculated before the pivot table is
created. Currently the code reads as below:

Range("A1").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,
SourceData:="'Sheet1'!R1C1:R9166C5").CreatePivotTa ble
TableDestination:="", TableName:="PivotTable1".

As I am new at coding, I would appreciate it, if you could
provide detailed instructions.

Many thanks

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

Use a defined name to define the source data.

Insert =Name = Define

Name := MyData
RefersTo:=
=Offset(Sheet1!$A$1,0,0,CountA(Sheet1!$A:$A),Count A(Sheet1!$1:$1))

click the ADD button

now make this the source for your Pivot Table.

--
Regards,
Tom Ogilvy



"Help Required!" wrote in message
...
Hi,

I am relatively new to writing code and in most cases
record a macro which I then manipulate to meet my needs.
So the question I am about to ask may sound very simple to
most of you....!

I have macro that basically collects data from an external
data source. The query has a few parameter queries in it
which allows the user to selet the criteria they want, so
changing the size of the data source each time. The macro
then uses the data to create a pivot table.

The problem I am having is the pivot table uses a hard
coded value for the datasource. As the records in the
datasource can change depending on criteria, the pivot
table can be correct. How can I ensure the datasource can
be dynamically calculated before the pivot table is
created. Currently the code reads as below:

Range("A1").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,
SourceData:="'Sheet1'!R1C1:R9166C5").CreatePivotTa ble
TableDestination:="", TableName:="PivotTable1".

As I am new at coding, I would appreciate it, if you could
provide detailed instructions.

Many thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Coding for Pivot Table

How do I make this the source for my pivot table? Directly
in the coding?

Sorry - new at this!
-----Original Message-----
Use a defined name to define the source data.

Insert =Name = Define

Name := MyData
RefersTo:=
=Offset(Sheet1!$A$1,0,0,CountA(Sheet1!$A:$A),Coun tA

(Sheet1!$1:$1))

click the ADD button

now make this the source for your Pivot Table.

--
Regards,
Tom Ogilvy



"Help Required!"

wrote in message
...
Hi,

I am relatively new to writing code and in most cases
record a macro which I then manipulate to meet my needs.
So the question I am about to ask may sound very simple

to
most of you....!

I have macro that basically collects data from an

external
data source. The query has a few parameter queries in it
which allows the user to selet the criteria they want,

so
changing the size of the data source each time. The

macro
then uses the data to create a pivot table.

The problem I am having is the pivot table uses a hard
coded value for the datasource. As the records in the
datasource can change depending on criteria, the pivot
table can be correct. How can I ensure the datasource

can
be dynamically calculated before the pivot table is
created. Currently the code reads as below:

Range("A1").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,
SourceData:="'Sheet1'!R1C1:R9166C5").CreatePivotTa ble
TableDestination:="", TableName:="PivotTable1".

As I am new at coding, I would appreciate it, if you

could
provide detailed instructions.

Many thanks



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Coding for Pivot Table

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


--
Regards,
Tom Ogilvy



"bmistry" wrote in message
...
How do I make this the source for my pivot table? Directly
in the coding?

Sorry - new at this!
-----Original Message-----
Use a defined name to define the source data.

Insert =Name = Define

Name := MyData
RefersTo:=
=Offset(Sheet1!$A$1,0,0,CountA(Sheet1!$A:$A),Coun tA

(Sheet1!$1:$1))

click the ADD button

now make this the source for your Pivot Table.

--
Regards,
Tom Ogilvy



"Help Required!"

wrote in message
...
Hi,

I am relatively new to writing code and in most cases
record a macro which I then manipulate to meet my needs.
So the question I am about to ask may sound very simple

to
most of you....!

I have macro that basically collects data from an

external
data source. The query has a few parameter queries in it
which allows the user to selet the criteria they want,

so
changing the size of the data source each time. The

macro
then uses the data to create a pivot table.

The problem I am having is the pivot table uses a hard
coded value for the datasource. As the records in the
datasource can change depending on criteria, the pivot
table can be correct. How can I ensure the datasource

can
be dynamically calculated before the pivot table is
created. Currently the code reads as below:

Range("A1").Select
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase,
SourceData:="'Sheet1'!R1C1:R9166C5").CreatePivotTa ble
TableDestination:="", TableName:="PivotTable1".

As I am new at coding, I would appreciate it, if you

could
provide detailed instructions.

Many thanks



.



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
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
Pivot table field coding Jesse Hamilton Excel Programming 0 October 10th 03 06:20 AM
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 12:06 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"