I want to "flatten" a pivot table via the ConvertToFormulas
function and copy the result into the clipboard.
My code looks something like this:
ActiveSheet.PivotTables(1).ConvertToFormulas True
Range("A1").Select
ActiveCell.CurrentRegion.Select
Application.CutCopyMode = False
Selection.Copy
My problem is that not all cells are fully loaded from the datasource (they show #GETTING_DATA
) when my Selection.Copy
executes and I am left with cells in the clipboard that contain the text "#GETTING_DATA".
I would like to find a way to wait until all the cells are loaded or at least to wait 10s until (hopefully) all cells are loaded.
I have tried to add
Application.Wait(Now + TimeValue("0:00:10"))
or
Sleep(10000)
before Copy
but this seams to block the thread on which the loading of the cells is done and I am left with with the same result after 10s.