#1   Report Post  
nc
 
Posts: n/a
Default Pivottable

I am trying to sort my data first and then refresh pivot tables using the
following macro,

Private Sub Worksheet_Change(ByVal Target As Range)

Range("Data1").Sort Key1:=Range("P18"), Order1:=xlAscending,
Header:=xlYes, _
OrderCustom:=10, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

ActiveWorkbook.RefreshAll

End Sub


The problem is that the pivottables are not refreshing correctly.

Is the reason due to the fact that the data being sorted has not completed
when the pivot starts to refresh?


  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

I don't think so.

But I don't recall when just changing the sort order of my raw data would make
the pivottable even change (after it was refreshed).

One of the nice features of pivottables is that the raw data can be in any
order.



nc wrote:

I am trying to sort my data first and then refresh pivot tables using the
following macro,

Private Sub Worksheet_Change(ByVal Target As Range)

Range("Data1").Sort Key1:=Range("P18"), Order1:=xlAscending,
Header:=xlYes, _
OrderCustom:=10, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

ActiveWorkbook.RefreshAll

End Sub


The problem is that the pivottables are not refreshing correctly.

Is the reason due to the fact that the data being sorted has not completed
when the pivot starts to refresh?


--

Dave Peterson
  #3   Report Post  
nc
 
Posts: n/a
Default

Dave

Thanks for your reply.

My data has an extra field containing a vlookup function, it's result
changes based on the order of the data.

Another point, the pivottable refreshes correctly when I click the pivot
refresh button manually or run a seperate macro with the refreshall keyword.





"Dave Peterson" wrote:

I don't think so.

But I don't recall when just changing the sort order of my raw data would make
the pivottable even change (after it was refreshed).

One of the nice features of pivottables is that the raw data can be in any
order.



nc wrote:

I am trying to sort my data first and then refresh pivot tables using the
following macro,

Private Sub Worksheet_Change(ByVal Target As Range)

Range("Data1").Sort Key1:=Range("P18"), Order1:=xlAscending,
Header:=xlYes, _
OrderCustom:=10, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

ActiveWorkbook.RefreshAll

End Sub


The problem is that the pivottables are not refreshing correctly.

Is the reason due to the fact that the data being sorted has not completed
when the pivot starts to refresh?


--

Dave Peterson

  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

Maybe adding

application.calculate

before the refreshall would help.

nc wrote:

Dave

Thanks for your reply.

My data has an extra field containing a vlookup function, it's result
changes based on the order of the data.

Another point, the pivottable refreshes correctly when I click the pivot
refresh button manually or run a seperate macro with the refreshall keyword.


"Dave Peterson" wrote:

I don't think so.

But I don't recall when just changing the sort order of my raw data would make
the pivottable even change (after it was refreshed).

One of the nice features of pivottables is that the raw data can be in any
order.



nc wrote:

I am trying to sort my data first and then refresh pivot tables using the
following macro,

Private Sub Worksheet_Change(ByVal Target As Range)

Range("Data1").Sort Key1:=Range("P18"), Order1:=xlAscending,
Header:=xlYes, _
OrderCustom:=10, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

ActiveWorkbook.RefreshAll

End Sub


The problem is that the pivottables are not refreshing correctly.

Is the reason due to the fact that the data being sorted has not completed
when the pivot starts to refresh?


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
nc
 
Posts: n/a
Default

Dave

Thanks a lot. This solved the problem.

"Dave Peterson" wrote:

Maybe adding

application.calculate

before the refreshall would help.

nc wrote:

Dave

Thanks for your reply.

My data has an extra field containing a vlookup function, it's result
changes based on the order of the data.

Another point, the pivottable refreshes correctly when I click the pivot
refresh button manually or run a seperate macro with the refreshall keyword.


"Dave Peterson" wrote:

I don't think so.

But I don't recall when just changing the sort order of my raw data would make
the pivottable even change (after it was refreshed).

One of the nice features of pivottables is that the raw data can be in any
order.



nc wrote:

I am trying to sort my data first and then refresh pivot tables using the
following macro,

Private Sub Worksheet_Change(ByVal Target As Range)

Range("Data1").Sort Key1:=Range("P18"), Order1:=xlAscending,
Header:=xlYes, _
OrderCustom:=10, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

ActiveWorkbook.RefreshAll

End Sub


The problem is that the pivottables are not refreshing correctly.

Is the reason due to the fact that the data being sorted has not completed
when the pivot starts to refresh?

--

Dave Peterson


--

Dave Peterson

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
Pivottable data field nc Excel Discussion (Misc queries) 0 September 30th 05 12:44 PM
Sorting in PivotTable Aaron Howe Excel Discussion (Misc queries) 5 July 12th 05 09:49 PM
Pivottable Dates JayBee Excel Discussion (Misc queries) 5 January 15th 05 08:43 PM
PivotTable canned functions doco Excel Discussion (Misc queries) 0 January 14th 05 03:52 PM
How do I set permanent secondary axis in PivotTable chart? Microlong Charts and Charting in Excel 3 January 8th 05 03:54 AM


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