programsam
Board Regular
- Joined
- Feb 10, 2016
- Messages
- 123
I have a sub that refreshes a series of object tables, queries tables and Pivot Tables and when it transitions to the Pivot section, it triggers a "Run-time erorr '424': Object required" and it does not give me the option to debug. When I close out the prompt, Excel then tries to close out the file. If I go in to Visual Basic and try to iterate through the code line-by-line, I get no errors.
I added in the Application.StatusBar code ahead of every table refresh so that, while running automated, I could pinpoint where exactly the error is occuring and it seems to trigger in this area...
I'm stumped, thoughts?
I added in the Application.StatusBar code ahead of every table refresh so that, while running automated, I could pinpoint where exactly the error is occuring and it seems to trigger in this area...
VBA Code:
wb.Application.StatusBar = "ACTIVATING PIVOT TABLES"
wb.Application.StatusBar = "Refreshing SHIPPED Pivot Table..."
wb.Sheets("SHIPPED").Select
wb.ActiveSheet.PivotTables("SHIPPED").PivotCache.Refresh
I'm stumped, thoughts?
VBA Code:
Sub refreshTables()
Dim wb As Workbook
Set wb = ThisWorkbook
wb.Application.StatusBar = "Activating QUERIES..."
wb.Application.StatusBar = "Updating Shipped Orders TABLE..."
wb.Sheets("SHIPPED_ORDERS").Activate
wb.Sheets("SHIPPED_ORDERS").ListObjects(1).Refresh
Application.CalculateUntilAsyncQueriesDone
wb.Application.StatusBar = "Updating New Orders TABLE..."
wb.Sheets("NEW_ORDERS").Activate
wb.Sheets("NEW_ORDERS").ListObjects(1).Refresh
Application.CalculateUntilAsyncQueriesDone
wb.Application.StatusBar = "Refreshing YTD Data QUERY..."
wb.Sheets("YTD_DATA").Activate
wb.Connections("Query - YTD_SALES").Refresh
Application.CalculateUntilAsyncQueriesDone
wb.Application.StatusBar = "Refreshing QTD Data QUERY..."
wb.Sheets("QTD_DATA").Activate
wb.Connections("Query - QTD_SALES").Refresh
Application.CalculateUntilAsyncQueriesDone
wb.Application.StatusBar = "Refreshing MTD Data QUERY..."
wb.Sheets("MTD_DATA").Activate
wb.Connections("Query - MTD_SALES").Refresh
Application.CalculateUntilAsyncQueriesDone
wb.Application.StatusBar = "Refreshing Daily Data QUERY..."
wb.Sheets("DAILY_DATA").Activate
wb.Connections("Query - DAILY_SALES").Refresh
Application.CalculateUntilAsyncQueriesDone
wb.Application.StatusBar = "ACTIVATING PIVOT TABLES"
wb.Application.StatusBar = "Refreshing SHIPPED Pivot Table..."
wb.Sheets("SHIPPED").Select
wb.ActiveSheet.PivotTables("SHIPPED").PivotCache.Refresh
wb.Application.StatusBar = "Refreshing NEW ORDERS Pivot Table..."
wb.Sheets("NEW ORDERS").Select
wb.ActiveSheet.PivotTables("NEW ORDERS").PivotCache.Refresh
wb.Application.StatusBar = "Refreshing SUPS Pivot Table..."
wb.Sheets("SUPERVISORS").Select
wb.ActiveSheet.PivotTables("SUPS").PivotCache.Refresh
wb.Application.StatusBar = "Refreshing SALES Pivot Table..."
wb.Sheets("SALES").Select
wb.ActiveSheet.PivotTables("DAILY_ISR").PivotCache.Refresh
wb.ActiveSheet.PivotTables("MTD_ISR").PivotCache.Refresh
wb.ActiveSheet.PivotTables("QTD_ISR").PivotCache.Refresh
wb.ActiveSheet.PivotTables("YTD_ISR").PivotCache.Refresh
wb.Application.StatusBar = "Refreshing SUMMARY Pivot Table..."
wb.Sheets("SUMMARY").Select
wb.ActiveSheet.PivotTables("ISR_AOV").PivotCache.Refresh
wb.ActiveSheet.PivotTables("SHIP_RANK").PivotCache.Refresh
wb.ActiveSheet.PivotTables("NEW_RANK").PivotCache.Refresh
wb.ActiveSheet.PivotTables("LEADS_BREAKDOWN").PivotCache.Refresh
wb.Application.StatusBar = "Activating BONUS..."
wb.Application.StatusBar = "Refreshing BONUS Table..."
wb.Sheets("BONUS").Activate
wb.Sheets("BONUS").ListObjects(1).Refresh
Application.CalculateUntilAsyncQueriesDone
End Sub
[ATTACH type="full" alt="1706106957111.png"]105631[/ATTACH]