I am working with an application that invokes/uses excel 2007.
Application gets data from Oracle database and populates it into a worksheet. It sorts it based on 4 columns. (code pasted below)
Then, it invokes some macros (vba code) which basically refreshes 2 pivot tables (code is pasted below).
Issue I am running into is when there are 285,000 rows in the worksheet, vba code fails while trying to refresh the pivot table (error text is something like 'Refresh method of pivot table failed'). I also get a popup error message 'excel cannot complete task with available resources. choose less data or close other applications' .....I get this message even when I manually refresh the pivot table.
...However if I save the worksheet (deleting the pivot etc) into a different file as CSV , then delete the data from the old worksheet and import the data from CSV, I am able to manually refresh the pivot tables !
what may be causing the issue with the pivot refresh of the original worksheet and how to resolve it?
Any assistance in this regards is appreciated.
thanks.
Here is the VBA code:
'sort raw data columns in the order Admin Dept number, name , rolename
Set w = ThisWorkbook.Sheets("Raw Data")
w.Select
With w.Sort
.SortFields.Clear
.SortFields.Add Key:=Range("D4"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.SortFields.Add Key:=Range("C4"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.SortFields.Add Key:=Range("J4"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.SortFields.Add Key:=Range("K4"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.SetRange Range(Range("B4"), Range("B4").SpecialCells(xlLastCell))
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Dim PC As PivotCache
For Each PC In ActiveWorkbook.PivotCaches
PC.Refresh
Next PC
Application gets data from Oracle database and populates it into a worksheet. It sorts it based on 4 columns. (code pasted below)
Then, it invokes some macros (vba code) which basically refreshes 2 pivot tables (code is pasted below).
Issue I am running into is when there are 285,000 rows in the worksheet, vba code fails while trying to refresh the pivot table (error text is something like 'Refresh method of pivot table failed'). I also get a popup error message 'excel cannot complete task with available resources. choose less data or close other applications' .....I get this message even when I manually refresh the pivot table.
...However if I save the worksheet (deleting the pivot etc) into a different file as CSV , then delete the data from the old worksheet and import the data from CSV, I am able to manually refresh the pivot tables !
what may be causing the issue with the pivot refresh of the original worksheet and how to resolve it?
Any assistance in this regards is appreciated.
thanks.
Here is the VBA code:
'sort raw data columns in the order Admin Dept number, name , rolename
Set w = ThisWorkbook.Sheets("Raw Data")
w.Select
With w.Sort
.SortFields.Clear
.SortFields.Add Key:=Range("D4"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.SortFields.Add Key:=Range("C4"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.SortFields.Add Key:=Range("J4"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.SortFields.Add Key:=Range("K4"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.SetRange Range(Range("B4"), Range("B4").SpecialCells(xlLastCell))
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Dim PC As PivotCache
For Each PC In ActiveWorkbook.PivotCaches
PC.Refresh
Next PC