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

Can someone help me with this?
I need a Pivot table to change data according to information in a particular
cell through VB.
For example: if cell M3 is 3500 I want the Pivot table to show the
information for 3500. My poor attempt below

ActiveSheet.PivotTables("PivotTable2").PivotFields ("ID").CurrentPage =
"RANGE (M3)"

I can do it using IF's:

If ActiveCell = 3500 Then
ActiveSheet.PivotTables("PivotTable2").PivotFields ("ID").CurrentPage =
"3500"
End if

But I would end up with an extremely long code, because there are up to 3500
combinations.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Pivot Table - VBA

ActiveSheet.PivotTables("PivotTable2") _
.PivotFields("ID").CurrentPage = RANGE("M3").Text

Should work if M3 is on the same pate as the pivot table.

if not, you need to specify where it is

ActiveSheet.PivotTables("PivotTable2") _
.PivotFields("ID").CurrentPage = _
worksheets("sheet3").RANGE("M3").Text

--
Regards,
Tom Ogilvy



"JohnUK" wrote in message
...
Can someone help me with this?
I need a Pivot table to change data according to information in a

particular
cell through VB.
For example: if cell M3 is 3500 I want the Pivot table to show the
information for 3500. My poor attempt below

ActiveSheet.PivotTables("PivotTable2").PivotFields ("ID").CurrentPage =
"RANGE (M3)"

I can do it using IF's:

If ActiveCell = 3500 Then
ActiveSheet.PivotTables("PivotTable2").PivotFields ("ID").CurrentPage =
"3500"
End if

But I would end up with an extremely long code, because there are up to

3500
combinations.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Pivot Table - VBA

Many thanks Tom, it worked a treat
John
-----Original Message-----
ActiveSheet.PivotTables("PivotTable2") _
.PivotFields("ID").CurrentPage = RANGE("M3").Text

Should work if M3 is on the same pate as the pivot table.

if not, you need to specify where it is

ActiveSheet.PivotTables("PivotTable2") _
.PivotFields("ID").CurrentPage = _
worksheets("sheet3").RANGE("M3").Text

--
Regards,
Tom Ogilvy



"JohnUK" wrote in

message
news:8E93CCC2-A05F-4EF8-84F8-

...
Can someone help me with this?
I need a Pivot table to change data according to

information in a
particular
cell through VB.
For example: if cell M3 is 3500 I want the Pivot table

to show the
information for 3500. My poor attempt below

ActiveSheet.PivotTables("PivotTable2").PivotFields

("ID").CurrentPage =
"RANGE (M3)"

I can do it using IF's:

If ActiveCell = 3500 Then
ActiveSheet.PivotTables("PivotTable2").PivotFields

("ID").CurrentPage =
"3500"
End if

But I would end up with an extremely long code,

because there are up to
3500
combinations.



.

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
Filter lines with Pivot table and non Pivot table columns Grover Excel Discussion (Misc queries) 1 September 26th 07 12:48 AM
Filter lines containing pivot table and non pivot table data Grover Excel Worksheet Functions 0 September 24th 07 07:20 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
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 05:43 PM.

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"