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

Hi
I have a number of pivot tables that have filters to be slected by the user,
but I want to auto select the value using field values held in another
worksheet, Currrently when the user selects a value form the other worksheet
(using a drop down box) various calculations are done and this prompts teh
users to select certain values in the other worksheets.

I have tried the follwoing code which sometimes works but at other times it
doesn't and being a complete VBA novice I don't know what I'm doing wrong

Sheets("Contract totals").Select
ActiveSheeet.PivotTables("Shares_select").Pivotfie lds
("Netreins").CurrentPage.Name = Range("X2")


It doesn't seem to like the Range("X2") which is a field on the spreadsheet
that is linked to a value on the source worksheet. I would rahter it point to
the actual other worksheet file but I don't know how to achive that.

Anyone any ideas?

regards
John



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Pivot table auto field selection

Assume the sheet with the pivottable is named PTbleSheetname and the sheet
with the source data is named SourceSheetName. Then you could do:

Worksheets("PTbleSheetName").PivotTables( _
"Shares_select").Pivotfields _
("Netreins").CurrentPage.Name = _
Worksheets("SourceSheetName").Range("X2").Value



--
Regards,
Tom Ogilvy


"JohnC" wrote:

Hi
I have a number of pivot tables that have filters to be slected by the user,
but I want to auto select the value using field values held in another
worksheet, Currrently when the user selects a value form the other worksheet
(using a drop down box) various calculations are done and this prompts teh
users to select certain values in the other worksheets.

I have tried the follwoing code which sometimes works but at other times it
doesn't and being a complete VBA novice I don't know what I'm doing wrong

Sheets("Contract totals").Select
ActiveSheeet.PivotTables("Shares_select").Pivotfie lds
("Netreins").CurrentPage.Name = Range("X2")


It doesn't seem to like the Range("X2") which is a field on the spreadsheet
that is linked to a value on the source worksheet. I would rahter it point to
the actual other worksheet file but I don't know how to achive that.

Anyone any ideas?

regards
John



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Pivot table auto field selection

Hii Tom
Many thanks for your reply.

I have used your code and it is now working although hI have made a slight
amendemnt to your code. I have removed the .Name after the CurrentPage as I
ws getting a 'Run time error 1004
'Unable to set the Name property of the PivotItem class
I don't know why but found the answer by trial and error....hopefully!


One other question for anyone. Is it possible to test that the value the
PivotField is being changed to actually exists in the listing without the
macro bombing out?

Regards
John




"Tom Ogilvy" wrote:

Assume the sheet with the pivottable is named PTbleSheetname and the sheet
with the source data is named SourceSheetName. Then you could do:

Worksheets("PTbleSheetName").PivotTables( _
"Shares_select").Pivotfields _
("Netreins").CurrentPage.Name = _
Worksheets("SourceSheetName").Range("X2").Value



--
Regards,
Tom Ogilvy


"JohnC" wrote:

Hi
I have a number of pivot tables that have filters to be slected by the user,
but I want to auto select the value using field values held in another
worksheet, Currrently when the user selects a value form the other worksheet
(using a drop down box) various calculations are done and this prompts teh
users to select certain values in the other worksheets.

I have tried the follwoing code which sometimes works but at other times it
doesn't and being a complete VBA novice I don't know what I'm doing wrong

Sheets("Contract totals").Select
ActiveSheeet.PivotTables("Shares_select").Pivotfie lds
("Netreins").CurrentPage.Name = Range("X2")


It doesn't seem to like the Range("X2") which is a field on the spreadsheet
that is linked to a value on the source worksheet. I would rahter it point to
the actual other worksheet file but I don't know how to achive that.

Anyone any ideas?

regards
John



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
Pivot Table field selection order Bony Pony[_2_] Excel Discussion (Misc queries) 7 June 12th 09 03:31 PM
Synchronize the Pivot table page field selection in 2 tables? Amk Excel Worksheet Functions 0 April 24th 09 06:42 PM
Multiple Field Selection for Pivot table Values Section [email protected] Excel Worksheet Functions 0 May 13th 08 03:03 PM
Selection of multiple values for pivot table field Michael Glenn Excel Discussion (Misc queries) 0 February 23rd 06 02:11 PM
Pivot Table - Multiple Pivot Field Selection Paul Mac.[_2_] Excel Programming 3 November 10th 03 01:13 PM


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