ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run-Time error 1004 Application defined or object defined error - (https://www.excelbanter.com/excel-programming/422354-run-time-error-1004-application-defined-object-defined-error.html)

WirelessPete

Run-Time error 1004 Application defined or object defined error -
 
I have an Excel 2007 application that connects to an OLAP database using a
pivot table. When the user changes a list box value in the workbook I refresh
the pivot table, which generates a new OLAP query. Works fine until the
spreadsheet sits for more than about 5 minutes, then I get a "Run-Time error
1004 Application defined or object defined error" on the first ActiveSheet
line.

Sub Update_CarrierDetailData(ByVal CurrentMarket As String, ByVal
CurrentSector As String)
Dim strCurrentSheet As String
Dim strCurrentCell As String

strCurrentSheet = ActiveSheet.Name
strCurrentCell = ActiveCell.Address
Sheets("CarrierDetail").Select


ActiveSheet.PivotTables("PivotTable2").PivotFields ( _
"[Carrier].[Market].[Market]").ClearAllFilters
ActiveSheet.PivotTables("PivotTable2").PivotFields ( _
"[Carrier].[Market].[Market]").CurrentPageName = _
"[Carrier].[Market].&[" & CurrentMarket & "]"

ActiveSheet.PivotTables("PivotTable2").PivotFields ( _
"[Carrier].[Sector].[Sector]").CurrentPageName = _
"[Carrier].[Sector].&[" & CurrentSector & "]"

Sheets(strCurrentSheet).Select
Range(strCurrentCell).Select

End Sub


All times are GMT +1. The time now is 06:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com