• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Timer or Stopwatch in Excel VBA|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Timer or Stopwatch in Excel VBA|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosTimer or Stopwatch in Excel VBA
sp_PrintTopic sp_TopicIcon
Timer or Stopwatch in Excel VBA
Avatar
Mike Vella

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
March 9, 2020
sp_UserOfflineSmall Offline
1
March 9, 2020 - 9:55 am
sp_Permalink sp_Print

Hi,

I would like to use a timer to run concurrently with a macro to complete a lengthy process matching information then creating and pdf-ing brochures.

But I would like the macro to activate and stop the timer automatically - not manually use command buttons.

When I try using the Timer code you published at the start of the macro it dominates the macro and won't allow the following processes to run.

Is there a way around this?? Your assistance would be appreciated.

 

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1514
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
March 9, 2020 - 12:25 pm
sp_Permalink sp_Print

Hi Mike,

Without seeing your code it's hard to say.  Are you using DoEvents?

An alternative approach is to just take a timestamp when your macro starts and another when it ends then work out the elapsed time.  Do you need to see elapsed time in real-time or just see how long the code took once it's finished?

Regards

Phil

Avatar
Mike Vella

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
March 9, 2020
sp_UserOfflineSmall Offline
3
March 9, 2020 - 8:18 pm
sp_Permalink sp_Print

Hi Phil,

I was using DoEvents, but without success.

I have gone to your idea of Time Stamping .. as I'm only interested in the net time, not the running time.

BUT .. I have unprotected the cells for the start and finish time stamps and protected the sheet.

Now the macro pulls up an 'Unable to set the NumberFormat property of the range class' even though the formatting of the respective cells corresponds with the time stamp format. I don't get this error is the sheet is not protected.

Any suggestions?

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1514
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
March 9, 2020 - 9:51 pm
sp_Permalink sp_Print sp_EditHistory

Hi Mike,

Without seeing your code I can only guess as to what you are doing.

But if you use this Sub then you should be able to work out the time it takes some code to run

 

Sub MyTimer()

Dim Start As Single, RunTime As Single
Dim ElapsedTime As String

Start = Timer

' Your code goes here 

ElapsedTime = Format((Timer - Start) / 86400, "hh:mm:ss")

End Sub

 

Regards

Phil

Avatar
Mike Vella

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
March 9, 2020
sp_UserOfflineSmall Offline
5
March 10, 2020 - 3:52 pm
sp_Permalink sp_Print

Hi Phil,

After much playing around I've decided to dump the idea as I couldn't get any scenario to work satisfactorily.

The Workbooks I've created are 41mb and 57mb, and formula intense.

What I've found (apart from not getting any to work in a Protected Sheet) was that the timer would trigger the calculate function.

This normally wouldn't be an issue, however it was forcing the whole spreadsheet to re-calc, a time consuming process that would be triggered regularly by the timer.

I intend to try and market these spreadsheets as they are perculiar to the building industry and need to be a protected worksheets.

So, thanks for your help all the same, I'm sure I'll trip over another problem that will need your expertise :).

Regards,

Mike

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1514
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
6
March 10, 2020 - 5:23 pm
sp_Permalink sp_Print

Hi Mike,

Running the MyTimer code above shouldn't trigger calculation.  hmmmm.

Not knowing what you are doing in these workbooks, but judging by the size, perhaps storing your data in a SQL database and using Power Query or Power BI might be an option for you?

But, I don't know what you are trying to do so they are just suggestions.

Regards

Phil

Avatar
Mike Vella

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
March 9, 2020
sp_UserOfflineSmall Offline
7
March 11, 2020 - 6:01 pm
sp_Permalink sp_Print

Hi Phil,

The whole exercise revolves around matching land with house designs. An exercise generally performed between Sales, the Estimator and the Draftsman. 

My concept combines all the activities into the two spreadsheets, where the uninitiated can simply input basic information and the program determines the parameters for each lot then matches them with the parameters for each design, taking into account council or individual subdivision requirements. The net result is it produces a price for a house-land package and marries this with a preformatted brochure. The resulting pdf is automatically filed according to a predetermined folder set up.

Sound simple, but it is an extensive filtering process that changes with lot width, depth, design, subdivision, etc, etc. I considered creating this in a database, but the conditional statements would be unworkable. I've even split some formula into two or three so I can follow and correct them. Spreadsheets give you 'room to move' so to speak.

I've got it completed now. My recent test had the program creating just over a 1,000 different pdf brochures in less than an hour. The timer was to give the user an idea of how long each of the several different brochure types they want take to produce. Once they've seen the program run once they have an idea of how long to leave it alone and go on with something else.

Regards,

Mike

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Shanna Henseler, Lawrence Smith, Nada Perovic
Guest(s) 11
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
John Chisholm
vexokeb sdfg
John Jack
Malcolm Toy
Ray-Yu Yang
George Shihadeh
Naomi Rumble
Uwe von Gostomski
Jonathan Jones
drsven
Forum Stats:
Groups: 3
Forums: 24
Topics: 6212
Posts: 27236

 

Member Stats:
Guest Posters: 49
Members: 31889
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.