I have a macro that times how long each query takes to run and output the time to the immediate window.
I there a way to set it to output to cells?
Macro:
Sub TimeQueries()
Dim oSh As Worksheet
Dim oCn As WorkbookConnection
Dim dTime As Double
For Each oCn In ThisWorkbook.Connections
dTime = Timer
oCn.Ranges(1).ListObject.QueryTable.Refresh False
Debug.Print Timer - dTime, oCn.Name, oCn.Ranges(1).Address(external:=True)
Next
End Sub
Immediate Window Output:
6.609375 Query1 [YEtest.xlsm]Query1!$A$1:$S$3006
15.12109375 Query2 [YEtest.xlsm]Query2!$A$1:$S$3006
21.0703125 Query3 [YEtest.xlsm]Query3!$A$1:$S$3006
0.125 Query4 [YEtest.xlsm]Query4!$A$1:$B$2
Tab name I want it output to: Control