Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default Issue with refreshing pivot tables in my code

Hi,

The code below is not finishing when executed -- it just hangs up -- hitting
he "ESC" key doesn't even stop it -- Excle stops responding and I have to
shut it down completely when I execute this query. I did a lot of testing on
it by using "Stop" at various points in the code to see if I could determine
exactly what line of code is causing the issue. What I found is that it
doesn't appear to be any one line of code causing the issue...what I found is
that the code takes longer and longer to finish executing the further down I
place "Stop" until it finally completely stops responding where I noted below
('This is where the code hangs up).

Any idea on why this is happening? I am testing this code with very little
data (4-7 lines of data which is what each pivot table is using). I am now
experimenting with foregoing the pivot table in the code all together and
essentially duplicating what the pivot table does by using For..Next and
If..Then loops -- is it recommended that one not use pivot tables with macros
as they tend to cause the code to crash? Just wondering if that's the
case...thanks!

Sub identifyopentrans()

Dim salesrange
Dim payrange
Dim A 'Variable for Order ID within salesrange
Dim B 'Variable for Order ID within payrange
Dim c 'Variable to determine if Order ID in Sales report is also within
Payment report
Dim x 'Variable to determine what cell within "Open Transaction" sheet to
paste Order ID into
Dim Aamount
Dim Bamount

Sheets("Open Transactions").Visible = True

Sheets("Open Transactions").Activate
Range(Rows(2), Rows(2).End(xlDown)).ClearContents

Sheets("Payment Sales Master Pivot").Activate
ActiveSheet.PivotTables("PivotTable1").PivotCache. Refresh

Sheets("Member ID Report Master Pivot").Activate
ActiveSheet.PivotTables("PivotTable2").PivotCache. Refresh

Set salesrange = Worksheets("Member ID Report Master
Pivot").Range("A3").PivotTable.PivotFields("Order ID").DataRange
Set payrange = Worksheets("Payment Sales Master
Pivot").Range("A3").PivotTable.PivotFields("Order ID").DataRange

x = 1
For Each A In salesrange
c = 0
For Each B In payrange
If A = B Then
c = c + 1
End If
Next
If c < 1 Then
Sheets("Open Transactions").Range("D1").Offset(x, 0).value = A
Sheets("Open Transactions").Range("D1").Offset(x, -3).value =
Worksheets("Member ID Report Master Pivot").Range(A.Address()).Offset(0,
1).value
Sheets("Open Transactions").Range("D1").Offset(x, -2).value =
Worksheets("Member ID Report Master Pivot").Range(A.Address()).Offset(0,
2).value
Sheets("Open Transactions").Range("D1").Offset(x, -1).value =
Worksheets("Member ID Report Master Pivot").Range(A.Address()).Offset(0,
3).value
Sheets("Open Transactions").Range("D1").Offset(x, 1).value =
Worksheets("Member ID Report Master Pivot").Range(A.Address()).Offset(0,
4).value
Sheets("Open Transactions").Range("D1").Offset(x, 3).value =
"Payment not yet submitted for this Sales transaction"

x = x + 1

Else

'This is where the code hangs up

End If
Next

--
Robert
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
Refreshing Pivot Tables hnyb1 Excel Discussion (Misc queries) 1 September 13th 07 01:21 PM
When refreshing pivot tables my pivot table chart type changes hannah220507 Excel Discussion (Misc queries) 1 May 22nd 07 02:57 PM
Refreshing Pivot Tables Lisa Excel Worksheet Functions 2 May 17th 07 04:19 PM
Refreshing pivot tables matpj[_47_] Excel Programming 0 March 20th 06 03:40 PM
Refreshing all Pivot Tables in the On_Open() code Tony White Excel Programming 1 January 3rd 05 10:03 PM


All times are GMT +1. The time now is 11:16 AM.

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"