+ Reply to Thread
Results 1 to 9 of 9

Speed up Coding

  1. #1
    Registered User
    Join Date
    07-03-2023
    Location
    Tasmania, Australia
    MS-Off Ver
    Microsoft 365
    Posts
    5

    Post Speed up Coding

    Hi Everyone,

    First time writing VBA code and creating a "Program" as such. So i need some help. I have included my example document below.

    Note
    *The Modify Vehicle hasnt been coded as yet
    *This workbook will be bigger. It will have Vehicle Servicing, Reports on Vehicles, Reports on spending ect.
    *The Calendar userform and coding has been downloaded and copied from another website. (This runs quite slow)
    *Im wanting to limit my VBA Reference Library as i will be sharing this with friends and i dont know what their computer will have.

    Im looking at getting my coding checked to see if there is anything i can do to make it run faster or more efficiently (as the file will get alot bigger)
    Im wanting to know as well if there is a better way to reference my Renewal OptionsButtons(Option3M, Option6M, Option12M) and they are also linked to Label(Rego_3M, Rego_6M, Rego_12M) as well as the new expiry date (New_Date label) updates depending on selection

    Thank you so much
    Attached Files Attached Files

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Speed up Coding

    What exactly do you need help with?

    What needs speeding up?
    If posting code please use code tags, see here.

  3. #3
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: Speed up Coding

    The timer within the calendar is interrupting on a 1 sec frequency set it to 5 or 10 secs and see if there is a difference also on date selection the calendar hangs until you select the next textbox.
    Try to set focus onto the next control (textbox etc.) - ensure the 'tab' order is set - sometimes it is difficult to set focus to the next control when they are contained in different frames.
    You also have a dwell timer set if you change from 'Vehicle' sheet (what is its purpose and is it necessary)
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  4. #4
    Registered User
    Join Date
    07-03-2023
    Location
    Tasmania, Australia
    MS-Off Ver
    Microsoft 365
    Posts
    5

    Re: Speed up Coding

    Thank you for the reply.
    Can i remove the timer for the calendar all together? i dont use it.
    the dwell timer for the change sheet is to make sure that it changes the sheet before opening up the userform. If i have it 1 digit lower it opens before changing sheets.
    The tab order is all correct. How do i set focus to the next control? (is that by just writing the code at the end of the calendar one saying VCH_Rego.setfocus?
    I have noticed that when you select a date the mouse load symbol just goes on. But as soon as you click somewhere else it stops.

  5. #5
    Registered User
    Join Date
    07-03-2023
    Location
    Tasmania, Australia
    MS-Off Ver
    Microsoft 365
    Posts
    5

    Re: Speed up Coding

    The userform/Worksheet can be slow and lag. not sure if this is because of my laptop. But as its my first time writing VBA i wants pointers on where i can make it more efficient and run smoothly. I know i need to put Error handling in. But have no idea where to start with that either.

  6. #6
    Registered User
    Join Date
    07-03-2023
    Location
    Tasmania, Australia
    MS-Off Ver
    Microsoft 365
    Posts
    5

    Re: Speed up Coding

    I have updated a few things.
    *Rego Renewal i have created a function for the OptionButtons (Months3M, Months6M, Months12M) as well as the New date.
    I have also linked this in with the saving to get the input option.

    *Added Setfocus to the next object

    i havent removed the timer as of yet. Waiting for a reply above.
    Attached Files Attached Files

  7. #7
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: Speed up Coding

    I will have a look through the whole code in the next day or two, are you committed to that actual calendar (it is code heavy on tracking mouse position) - I had to stop the timer to enable me to view the calendar form in the VBA editor (which is unusual).
    From your profile I see you are using MS 365 o.s. however what version of Excel are you using and is it 32 bit or 64 bit.

  8. #8
    Registered User
    Join Date
    07-03-2023
    Location
    Tasmania, Australia
    MS-Off Ver
    Microsoft 365
    Posts
    5
    Quote Originally Posted by torachan View Post
    I will have a look through the whole code in the next day or two, are you committed to that actual calendar (it is code heavy on tracking mouse position) - I had to stop the timer to enable me to view the calendar form in the VBA editor (which is unusual).
    From your profile I see you are using MS 365 o.s. however what version of Excel are you using and is it 32 bit or 64 bit.
    Thank you.
    I'm using MS 365 32bit.
    I'm currently trying to change to rego ID dropdown on the renewal form. To only show regos that are due within the next 3 months (example. Select values from vehicle table if new rego is not blank then if new rego within 3 else if rego expiry date is within 3 months. But then if private or business is selected then it also only returns the values where it meets both values.

  9. #9
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: Speed up Coding

    give the attached a trial - there is only one userform with a multipage switching between the three buttons on your 'Vehicle' sheet.
    I am interested if you find it any faster as the mouse positioning updating in your original file seemed to slow things down.
    get back on this site if there are any further queries, I will do my best to answer.
    Attached Files Attached Files
    Last edited by torachan; 07-13-2023 at 01:37 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Speed controls, how to calculate average speed.
    By Hejhallo in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 04-07-2022, 06:33 AM
  2. Speed up the macro coding 150 sheets
    By rajuganapathy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-28-2019, 08:53 AM
  3. Speed up the macro coding
    By rajuganapathy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-26-2019, 10:39 PM
  4. How to avoid cell SELECTION but still format cells to speed up the macro running speed
    By BeefyBerts in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-05-2018, 08:18 AM
  5. [SOLVED] In need of help regarding combo box coding and button coding (Access form project)
    By mailblade in forum Access Tables & Databases
    Replies: 2
    Last Post: 01-09-2016, 01:34 AM
  6. Everage Speed km/time (european speed)
    By GerryZucca in forum Excel General
    Replies: 3
    Last Post: 02-23-2015, 03:02 PM
  7. How to make VBA offset and speed up coding
    By Toyo613 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-05-2014, 10:34 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1