Refreshing PivotTable in Excel 2007 VBA doesn't work -


i'm trying update pivot table vba after it's source sql data table refreshed. no matter do, pivot table refreshed 2nd time code executed. i've tried combinations , orders of pivot.refreshtable , pivot.update, adding events, setting application.screenupdating false before , true after. i'm running out of ideas. each time data modified in sql, have execute once see in source table , again see in pivot table.

dim c workbookconnection set c = thisworkbook.connections.item("sheet1")  ssql = "select * table1 "       c.oledbconnection.commandtext = ssql c.oledbconnection.commandtype = xlcmdsql c.refresh  each pivot in thisworkbook.worksheets("sheet1").pivottables      pivot.refreshtable     pivot.update     pivot.pivotcache.refresh     doevents     pivot.refreshtable     pivot.update     pivot.pivotcache.refresh next 

make sure connection doesn't refresh in background:

dim c workbookconnection set c = thisworkbook.connections.item("sheet1")  ssql = "select * table1 "       c.oledbconnection.commandtext = ssql c.oledbconnection.commandtype = xlcmdsql c.oledbconnection.backgroundquery = false c.refresh  each pivot in thisworkbook.worksheets("sheet1").pivottables      pivot.refreshtable  next 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -