Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1034879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:27:39+00:00 2026-05-16T14:27:39+00:00

This is Excel 2003. I’d like to know how long it takes an external

  • 0

This is Excel 2003.
I’d like to know how long it takes an external query to complete and then update a cell in my spreadsheet with that ET. I have the following, but it doesn’t work because the ET is only as long as it takes to initiate the refresh:

Sub Refresh()
    Dim StartTime, EndTime, ET

    StartTime = Timer
    ActiveWorkbook.RefreshAll
    EndTime = Timer
    ET = Format(EndTime - StartTime, "Fixed")
    Range("H27").Value = ET
    MsgBox (ET)
End Sub

So the ET is about 1 second, even though the data fetch takes a good 10 minutes.

The easy way out is to set background refresh to false, but this blocks the whole application and makes life miserable for a long time.

Is there some kind of signal or exception that I can catch in VBA that indicates “oh, a background refresh is done; now you can stop your timer and calculate the ET”?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:27:39+00:00Added an answer on May 16, 2026 at 2:27 pm

    I guess you need to use the AfterRefresh event.
    Here is a forum discussion with a happy ending and examples.

    Pasting the example from the referred page, just for link independence (you should add your timer storage and arithmetic):

    This code goes on a Module:

    Dim X As New Class1   
    Sub Initialize_It()   
      Application.DisplayAlerts = False 
      Application.ScreenUpdating = True  
      diropen = "C:\Desktop\" 
    
      Workbooks.Open diropen & "Test.xls" , UpdateLinks:=0 
    
      Set X.qt = Workbooks("Test.xls").Sheets("Sheet1").QueryTables(1)   
      ActiveWorkbook.RefreshAll 
    
    End Sub
    

    This code goes on a Class Module:

    Public WithEvents qt As QueryTable 
    Private Sub qt_AfterRefresh(ByVal Success As Boolean) 
    ' Declare variables. 
    Dim a As Integer 
    Dim My_Prompt As String 
    
    ' Initialize prompt text for message box. 
    My_Prompt = "Data refreshed or canceled."   
    
    ' Displays message box before refresh (or cancel) occurs. 
    MsgBox My_Prompt 
    
    ActiveWorkbook.Save 
    Workbooks("Test.xls").Close 
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel Spreadsheet like this id | data for id | more
I have created an Excel 2003 add-in that uses the CLR 2.0 and this
I have two columns in Excel, like this: A B 0.5 0.4 0.6 0.59
in excel 2003 row,column addresses are specified like A,1 and C,12 but in excel
There's this Excel file I want users to be able to download from my
If I am debugging (in this case a Visual Studio assembly called by Excel)
I'm using Automation to get_Text from an Excel worksheet. I do this because I
With SQL Server 2005 using SSMS, when I run this: SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel
Using something like this: try: # Something... except Exception as excep: logger = logging.getLogger(component)
This is a bit of a long shot, but if anyone can figure it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.