Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Problem with pivot index

Hi,

I have the following code - it fails on the row where I put the stars. Could
you help me please?

The intention is for it to copy and paste a pivot table (with other cells)
and change the page field of each pivot as it is pasted.

Private Sub CommandButton1_Click()

Dim CountryList As Range
Dim CountryNum As Integer
Dim CopyRange As Range

Application.ScreenUpdating = False

ActiveSheet.PivotTables("PvtCountry1").PivotFields ("Investigator
Country"). _
CurrentPage = "(blank)"
For Each CountryList In Sheets("Country
Analysis").Range("Country_List").Cells

CountryNum = ActiveSheet.PivotTables.Count

If CountryNum = 1 Then
Set CopyRange = Range("A11:G" & Cells(Rows.Count,
"B").End(xlUp).Row + 1)
Else
CopyRange.Copy
Range("A" & Cells(Rows.Count, "B").End(xlUp).Row + 2).Paste
End If

If CountryList < "" Then
ActiveSheet.PivotTables(CountryNum).PivotFields("I nvestigator
Country"). _
CurrentPage = CountryList '*********************
End If
Next CountryList

Range("A2").Select


Application.ScreenUpdating = True
FrmOptimize.Hide

End Sub

Thanks,

Basil
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Problem with pivot index

Countrylist is defined as a range object

despite value being the default property try
CurrentPage = CountryList.Value

might work in Xl2003, but not sure whether it'll work in 2007.

You have to make sure the value of Countrylist is actually present in
the pivottable field "Investigator
Country", otherwise this can be another reason for an error.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Problem with pivot index

Found a solution.
For some odd reason, when it copys and pastes a pivot table to the rows
beneath, the new pivot table that has been created gains the index 1. I
though pivottables(1) would be the one at the top, and as you add them
beneath it would go to pivottables(2) etc.

Anyone know how that works?

"Basil" wrote:

Hi,

I have the following code - it fails on the row where I put the stars. Could
you help me please?

The intention is for it to copy and paste a pivot table (with other cells)
and change the page field of each pivot as it is pasted.

Private Sub CommandButton1_Click()

Dim CountryList As Range
Dim CountryNum As Integer
Dim CopyRange As Range

Application.ScreenUpdating = False

ActiveSheet.PivotTables("PvtCountry1").PivotFields ("Investigator
Country"). _
CurrentPage = "(blank)"
For Each CountryList In Sheets("Country
Analysis").Range("Country_List").Cells

CountryNum = ActiveSheet.PivotTables.Count

If CountryNum = 1 Then
Set CopyRange = Range("A11:G" & Cells(Rows.Count,
"B").End(xlUp).Row + 1)
Else
CopyRange.Copy
Range("A" & Cells(Rows.Count, "B").End(xlUp).Row + 2).Paste
End If

If CountryList < "" Then
ActiveSheet.PivotTables(CountryNum).PivotFields("I nvestigator
Country"). _
CurrentPage = CountryList '*********************
End If
Next CountryList

Range("A2").Select


Application.ScreenUpdating = True
FrmOptimize.Hide

End Sub

Thanks,

Basil

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
Index on pivot report filter tablemanners Excel Worksheet Functions 0 February 22nd 10 11:58 AM
Index Problem Tracey Excel Worksheet Functions 5 February 1st 08 10:27 PM
=Index Problem Nikki Excel Discussion (Misc queries) 5 September 30th 07 11:18 PM
INDEX PROBLEM...I THINK Steve Excel Worksheet Functions 15 February 20th 07 09:28 PM
INDEX problem malik641 Excel Worksheet Functions 7 July 7th 05 01:50 PM


All times are GMT +1. The time now is 02:42 AM.

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"