Hello,
I have a connection to another excel file. Where I bring in data.
In my code, I refresh the connection. then update a pivot table.
It appears that the code goes so fast that it calls refresh, and while it refreshes the pivot table gets called.
Thus my pivot table has old data.
I looked at this
http://msdn.microsoft.com/en-us/libr.../ff834459.aspx
And my code now looks like this
Dim sCurrentSheet As String
Dim wsCurrentSheet As Worksheet
Dim pts As Range
Dim pt As PivotTables
Dim pti As Integer
Dim tblName As String
Dim lo As ListObjects
Dim loi As Integer
ptsNumber = 1
For i = 3 To Worksheets.Count
Set wsCurrentSheet = Excel.ActiveWorkbook.Worksheets(i)
Set lo = wsCurrentSheet.ListObjects
loi = lo.Count
For j = 1 To loi
If (CheckFile(lo(j).QueryTable.SourceDataFile)) Then
lo(j).refresh
'########## Here is the delay code #############
With lo(j).QueryTable
If .Refreshing Then
Else
.refresh BackgroundQuery:=False
End If
End With
End If
Next j
but it does not seem to work.
any ideas on delaying till refresh is done?
thanks
Bookmarks