How To Finish pivot table refresh before cont. VBA code

G

graham

First off, thanks for all the help from everyone in getting me this far!!

I'm so close to finishing this but have one problem, I'm trying to Auto_run a macro in a different workbook that opens an existing file, refreshes the pivot table, saves, then closes excel completely. My only problem is that my code trys to close excel before the refresh is complete. How can I tell it to finish the refresh operation before continuing?

THANKS!!!

ChDir "T:\Data\"
Workbooks.Open Filename:= _
"T:\Data\file.xls"
ActiveSheet.PivotTables("PivotTable1").RefreshTable
ActiveWorkbook.Save
ActiveWindow.Close
Set excelApp = GetObject(, "Excel.Application")
excelApp.Quit
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top