+ Reply to Thread
Results 1 to 33 of 33

Improve Speed of Codes in Workbook

  1. #1
    Banned User!
    Join Date
    08-02-2022
    Location
    US
    MS-Off Ver
    365
    Posts
    188

    Improve Speed of Codes in Workbook

    Hello,

    I removed most of the data because some of the coding was taking so long to run. I was wondering if someone has the time to check to see if the codes can be improved to run much faster. Without much data it doesn't seem too slow but with a lot of data it bogs down.

    I really appreciate your help,
    Rupert

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

    Re: Improve Speed of Codes in Workbook

    Please do not take this as criticism, in post #3 of the link below, I was trying to subtly point out the case you would face with the track you were taking.
    Excel is a very poor graphics program - you are coupling an artistic interface with multiple sheets some of which have formula in that the entirety calculate at every data entry.
    All of this is unnecessary 'bloat' - the nature of your app is that of a 'pseudo' database - the primary objective is the storage of data - use your sheets in the most simple/basic form you can - get rid of on sheet formula that react to every input.
    The 'artistic' refreshing of sheet formatting/colours/fill add nothing to the primary purpose of data handling - use simple elementary bespoke UserForm interface - use code instead of formula that will only alter the relevant data point.
    Regrettably at this point I am unable to post code or files as some of us are experiencing problems with the site - I have attempted several time to reply to your post with regard to date/currency formatting.
    As stated at the beginning, please do not take this as criticism, we have all been on 'learning curves' some of us longer than others.
    Torachan,

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

  3. #3
    Banned User!
    Join Date
    08-02-2022
    Location
    US
    MS-Off Ver
    365
    Posts
    188

    Re: Improve Speed of Codes in Workbook

    I kind of appreciate what you are saying but the codes are inefficient and if you are not able to provide a solution on how to improve them then why did you answer this thread?

    I want to enjoy using Excel and to have nice formatting for me is important. If it doesn't have nice graphics then like I mentioned the other day paper and pencil method to get the results.

    I hope someone else can provide some arrays or perhaps some advanced code filtering to get the codes to run faster.

    Thank you

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

    Re: Improve Speed of Codes in Workbook

    O.K. I will step back - I have obviously offended - with 50+ years of experience I was only trying to save you the pain of hitting your head against the wall.

  5. #5
    Banned User!
    Join Date
    08-02-2022
    Location
    US
    MS-Off Ver
    365
    Posts
    188

    Re: Improve Speed of Codes in Workbook

    I have hit me head many times to try to improve my abilities. Without trying how will I learn?

    I would rather learn how to fish than to be provided a fish.

  6. #6
    Valued Forum Contributor
    Join Date
    05-03-2022
    Location
    Halifax,Canada
    MS-Off Ver
    365
    Posts
    326

    Re: Improve Speed of Codes in Workbook

    Hello 75Rupert:
    There is a lot of code in the workbook. Is there a particular macro/process that's running slower than the rest that we could start with ?

    If this is your first project it is very ambitious

    And by-the-way ... I think you should show Torachan a little more respect. The experts here have a serious amount of knowledge and give it away here for free.
    Your code , though ambitious has many brittle areas that could easily cause issues in the future
    Last edited by nimrod1313; 08-18-2022 at 08:51 AM.

  7. #7
    Banned User!
    Join Date
    08-02-2022
    Location
    US
    MS-Off Ver
    365
    Posts
    188

    Re: Improve Speed of Codes in Workbook

    I did not mean any disrespect at all. For what I have said I am very sorry Torachan.

    I eventually want to protect some areas of the workbook.

    In particular the filters are slow with a lot of data. These are launched from the Interface and Report sheets.

    Thank you very much

  8. #8
    Banned User!
    Join Date
    08-02-2022
    Location
    US
    MS-Off Ver
    365
    Posts
    188

    Re: Improve Speed of Codes in Workbook

    I understand completely if I do not get any help.

    My comments obviously were offensive so I will leave now and try through my limited abilities to get my workbook to function more efficiently.

    Thank you everyone.

    I wish you all the best!

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

    Re: Improve Speed of Codes in Workbook

    @75Rupert, no offence taken, we are here to help, at times the 'email' type medium is not the best communications platform and mistranslations of points of view can be obtuse.
    However it can be equally frustrating to us when despite well meaning advice backed up by vast experience is discounted as an inconvenience.
    I wish you well in your endeavours.

  10. #10
    Valued Forum Contributor
    Join Date
    05-03-2022
    Location
    Halifax,Canada
    MS-Off Ver
    365
    Posts
    326

    Re: Improve Speed of Codes in Workbook

    I understand completely if I do not get any help.
    Hello 75Rupert:

    I have had my tone misinterpreted while posting so I empathize with you and torachan
    I am certainly willing to help you with your coding issues. If you could help me out and indicate which macro/process is effecting you the most I would start by taking a look at that for you.

    .... You mention the filters ... is there a specific macro that activates these ??
    Last edited by nimrod1313; 08-18-2022 at 10:10 AM.

  11. #11
    Banned User!
    Join Date
    08-02-2022
    Location
    US
    MS-Off Ver
    365
    Posts
    188

    Re: Improve Speed of Codes in Workbook

    Under the modules Filters and Filters 1 where the codes are located.

    Do you need any more details specifically?

  12. #12
    Valued Forum Contributor
    Join Date
    05-03-2022
    Location
    Halifax,Canada
    MS-Off Ver
    365
    Posts
    326

    Re: Improve Speed of Codes in Workbook

    Under the modules Filters and Filters 1 where the codes are located.
    I've started to dig through the code .... there is alot here to digest.

  13. #13
    Banned User!
    Join Date
    08-02-2022
    Location
    US
    MS-Off Ver
    365
    Posts
    188

    Re: Improve Speed of Codes in Workbook

    Please ask me about the functioning of the workbook if you need to.

    I basically altered what Trevor Easton designed back in 2013. Online PC Learning. He has a step by step process to apply the codes and formulas that I followed. Then there were 2 workbooks that got combined with some help from experts on here. I did some of the work also.

    I have hopes that once it is efficient that this system can provide some use for many others on here.

    Thank you so much for your help

  14. #14
    Valued Forum Contributor
    Join Date
    05-03-2022
    Location
    Halifax,Canada
    MS-Off Ver
    365
    Posts
    326

    Re: Improve Speed of Codes in Workbook

    Hello 75Rupert
    While starting to look at the filter code I noticed you reference the "interface" sheet as "sheet1" (ie. reference sheet by Code Number vs Sheet Name).
    I know this is a common practice but thought I should warn you about how fragile / unpredictable the code number can be.

    FOR EXAMPLE ...
    Here's screen shot of initial code number of "interface" sheet where the code number = 1
    ScrShotPreMove.gif

    then a user attempts to make a backup copy of sheet but forget to checkMark "copy" (common mistake)
    ScrShotCopy.gif

    .... after realizing mistake user quickly "move" sheet back to the original file (common solution to common mistake)
    .... and look at how the code number of "Interface" has changed ( ie. code number = 10 now)

    ScrShotPostMove.gif

    RESULT
    You now have code that will crash big time. And you will need to update your code in 18 places.
    This move/copy mistake does not affect the sheetName , only the code number.
    So referencing the sheet name would not have been as brittle.

    This is only 1 scenario of many.
    I had one scenario , involving code number reference , cost a retail client of mine over $100,000.
    An accountant wrote a macro involving sheet code number that ending up looking at backups of the pricing sheet that was very old .
    The company was releasing cost/pricing numbers to there over 300 retail stores on data that was way out of date.... a scenario that would NOT have happened if referenced sheets with the sheet name.
    Last edited by nimrod1313; 08-18-2022 at 11:39 AM.

  15. #15
    Banned User!
    Join Date
    08-02-2022
    Location
    US
    MS-Off Ver
    365
    Posts
    188

    Re: Improve Speed of Codes in Workbook

    So it should reference the actual sheet name instead of sheet1?

  16. #16
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Improve Speed of Codes in Workbook

    Nothing is foolproof. Generally codenames are better - but you should alter them from meaningless things like Sheet1.
    Everyone who confuses correlation and causation ends up dead.

  17. #17
    Valued Forum Contributor
    Join Date
    05-03-2022
    Location
    Halifax,Canada
    MS-Off Ver
    365
    Posts
    326

    Re: Improve Speed of Codes in Workbook

    Please Login or Register  to view this content.

  18. #18
    Valued Forum Contributor
    Join Date
    05-03-2022
    Location
    Halifax,Canada
    MS-Off Ver
    365
    Posts
    326

    Re: Improve Speed of Codes in Workbook

    Nothing is foolproof. Generally codenames are better
    No sheet code number are not better. ... in fact they're horrible
    When they break, (as you've said nothing if foolproof), they either (1) require coding experience to fix (2) or worse you don't know they're broken and code is referencing the wrong sheet.
    When the sheet name breaks it requires no coding experience to fix and never points to the wrong sheet.

    In my 20+ years of vba consulting I have had 0 occurances of having to fix a break because of a sheet referenced by name.
    However I've had numerous calls to fix code that used sheets code number. One in which the client had lost over $100,000 due to the mistake.

    I've heard arguments about this allows the sheet name to be changed on the fly as a great advantage.
    But to me that's one of the dangers. Macro's can easily end up pointing at the wrong sheet and keep processing.
    That's the scenario that cost my client $100,000 .. the macros for stock pricing updates were looking at old pricing sheet eg. "pricing backup 2020" instead of a sheet called "pricing"

    I can also write a couple of lines of code to check if sheet "pricing" exists and tell user if not found. (see my next post for example)
    How do you write code to message user that "sheet1" is missing ... and how do they fix the problem ??

    YOU ARE CORRECT ... NOTHING IS FOOLPROOF.
    So when it does break wouldn't you like it to be something obvious and fixable by the user ?
    Eg. msgbox saying "Missing sheet pricing" ... so user adds back the sheet
    vs
    msgbox saying "missing sheet sheet13" ... and having to call in someone with coding experience
    ... or worse ... the code just keeps on working on wrong sheet

    User's Message when using tab name as reference...

    scrShotMsg01.gif

    User's Message when using code number as reference ...

    scrShotMsg02.gif


    I've never found a scenario where I decided code number was a wiser way to go .
    Last edited by nimrod1313; 08-18-2022 at 01:24 PM.

  19. #19
    Registered User
    Join Date
    07-09-2019
    Location
    United State
    MS-Off Ver
    2019
    Posts
    53

    Re: Improve Speed of Codes in Workbook

    Hello,

    I apologize for posting this here, but this website will not allow me to post a new message nor send an email.

    I have been trying to post a message to the vba Forum for the past 3 days. I thought the problem might be that the website is migrating to a new server however I see others are posting.


    After I compose a message and hit submit, I get a message on my browser that says "This page isn't working" or "Excelforum is currently unable to handle this request." Http Error 500.

    Can you help?

    Thank you.
    Last edited by SKKS; 08-18-2022 at 12:46 PM.

  20. #20
    Valued Forum Contributor
    Join Date
    05-03-2022
    Location
    Halifax,Canada
    MS-Off Ver
    365
    Posts
    326

    Re: Improve Speed of Codes in Workbook

    No sheet code number are not better ... CONTINUED

    Method of testing if sheet exists in workbook.
    If found continue with macro.
    If not found alert user and exit macro.
    Note the re-usable function

    Please Login or Register  to view this content.
    Last edited by nimrod1313; 08-18-2022 at 01:25 PM.

  21. #21
    Banned User!
    Join Date
    08-02-2022
    Location
    US
    MS-Off Ver
    365
    Posts
    188

    Re: Improve Speed of Codes in Workbook

    I was not aware that there is a missing sheet. It didn't seem like any of the functions were disable but just slow when there was a lot of data.

  22. #22
    Valued Forum Contributor
    Join Date
    05-03-2022
    Location
    Halifax,Canada
    MS-Off Ver
    365
    Posts
    326

    Re: Improve Speed of Codes in Workbook

    Hello 75Rupert
    No there is no missing sheet , sorry , this was just a follow-up to discussion with rorya on using code numbers vs names.
    However my last code example is something I use in ALL my macros that reference a sheet.
    Eventually a user will rename or delete a sheet and this handles the problem effectively instead of the macro just crashing.

    All code/macros should have effective error handling for common problems , sheet deletion/rename is a common reason for errors in macros.
    Some people try to skirt the issue , instead of handling it , by using sheet code numbers , which can actually cause bigger problems. (see last post for discussion)


    Method of testing if sheet exists in workbook.
    If found continue with macro.
    If not found alert user and exit macro.
    Note the re-usable function

    Please Login or Register  to view this content.
    Last edited by nimrod1313; 08-18-2022 at 01:33 PM.

  23. #23
    Valued Forum Contributor
    Join Date
    05-03-2022
    Location
    Halifax,Canada
    MS-Off Ver
    365
    Posts
    326

    Re: Improve Speed of Codes in Workbook

    Hello Rupert:
    Sorry if i'm taking longer than expected , there's alot of code and I did get sidetracked by the discussion on sheet code names (ie. pet peave of mine).

    I'm having to run out for a little bit , but will look at it again a little later.
    Might I suggest you remove the "soleved" from this thread so you can get others also contributing ??

  24. #24
    Valued Forum Contributor
    Join Date
    05-03-2022
    Location
    Halifax,Canada
    MS-Off Ver
    365
    Posts
    326

    Re: Improve Speed of Codes in Workbook

    Hello Rupert:
    I'm attaching the first rough draft of code for copiing invoice info from summary sheet to interface sheet.
    Now this is rough in that it has lots of hardcoded references ... but I would be interested in you testing in a bulk data situation and see if it helps... before refining

    As requested this solution uses arrays for the transfer of data from 1 sheet to another.

    Please Login or Register  to view this content.
    Last edited by nimrod1313; 08-18-2022 at 03:50 PM.

  25. #25
    Banned User!
    Join Date
    08-02-2022
    Location
    US
    MS-Off Ver
    365
    Posts
    188

    Re: Improve Speed of Codes in Workbook

    Thanks sorry I was away. It looks like your code is only filtering for the summary sheet. The previous filter did both the Summary and Accounts sheets onto the Interface sheet.

    Am I wrong?

  26. #26
    Banned User!
    Join Date
    08-02-2022
    Location
    US
    MS-Off Ver
    365
    Posts
    188

    Re: Improve Speed of Codes in Workbook

    Maybe it is my older computer that is slow and not the codes?

  27. #27
    Banned User!
    Join Date
    08-02-2022
    Location
    US
    MS-Off Ver
    365
    Posts
    188

    Re: Improve Speed of Codes in Workbook

    I am upgrading my Ram from 8GB to 16GB to see if it helps. I should have the delivery tomorrow for the Ram cards (2 @ 8GB each).

  28. #28
    Banned User!
    Join Date
    08-02-2022
    Location
    US
    MS-Off Ver
    365
    Posts
    188

    Re: Improve Speed of Codes in Workbook

    Thank you @nimrod1313 for your efforts.

  29. #29
    Valued Forum Contributor
    Join Date
    05-03-2022
    Location
    Halifax,Canada
    MS-Off Ver
    365
    Posts
    326

    Re: Improve Speed of Codes in Workbook

    The previous filter did both the Summary and Accounts sheets onto the Interface sheet
    Hello Rupert
    you are correct , as I said I wanted you to try this rough draft to see if I was going in the right direction.
    Did you see any speed improvements ? Is this the type of thing you're looking for ? Should I proceed with the second part of the filter ?

  30. #30
    Banned User!
    Join Date
    08-02-2022
    Location
    US
    MS-Off Ver
    365
    Posts
    188

    Re: Improve Speed of Codes in Workbook

    It went to debug sorry.

  31. #31
    Banned User!
    Join Date
    08-02-2022
    Location
    US
    MS-Off Ver
    365
    Posts
    188

    Re: Improve Speed of Codes in Workbook

    I really think most of my issues are related to my PC. I will let you know at a later date.

  32. #32
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Improve Speed of Codes in Workbook

    Quote Originally Posted by nimrod1313 View Post
    No sheet code number are not better. ... in fact they're horrible
    That's your opinion.

    When they break, (as you've said nothing if foolproof), they either (1) require coding experience to fix (2) or worse you don't know they're broken and code is referencing the wrong sheet.
    They are less likely to break if used well, and the same applies to tab names (which are far more likely to be changed by a user.

    When the sheet name breaks it requires no coding experience to fix and never points to the wrong sheet.
    Never? Really?

    In my 20+ years of vba consulting I have had 0 occurances of having to fix a break because of a sheet referenced by name.
    However I've had numerous calls to fix code that used sheets code number. One in which the client had lost over $100,000 due to the mistake.
    And my experience has been the contrary. Users often change sheet names they decide they don't like.

    I've heard arguments about this allows the sheet name to be changed on the fly as a great advantage.
    But to me that's one of the dangers. Macro's can easily end up pointing at the wrong sheet and keep processing.
    Seems to me this contradicts your argument? Unless you're suggesting that users should be able to swap sheet names around so the code automatically processes a different sheet, in which case you have an odd model.

    [quote]I can also write a couple of lines of code to check if sheet "pricing" exists and tell user if not found. (see my next post for example)
    How do you write code to message user that "sheet1" is missing ...[quote]

    Same.

    and how do they fix the problem ??
    They don't. I wouldn't expect them to fix a serious error with the model, any more than I would expect them to fix a code glitch. If a user has removed a sheet that is integral to the model, why would I trust them to fix that correctly? That's why they pay me - support is included.

    As I said at the start, nothing is foolproof. Far better programmers than I recommend using codenames when appropriate (it's not always practical) and I have not had issues adopting that approach. I have had many instances where users rename worksheets and want to keep their new names and they are, the client, so...

    As with all things, your mileage may vary and you're entitled to do it your way. There are those who don't believe in declaring variables, or using meaningful names for anything, or unit testing, and if that works for them, I have no issue with it (as long as I never have to pick up their work).

  33. #33
    Banned User!
    Join Date
    08-02-2022
    Location
    US
    MS-Off Ver
    365
    Posts
    188

    Re: Improve Speed of Codes in Workbook

    I upgraded computer but the speed of the codes are still slow with the data.

+ 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. Improve speed of VBA code
    By markgoldmedal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-28-2021, 05:45 PM
  2. How to improve workflow and speed? help
    By amaterasu2302 in forum Excel General
    Replies: 3
    Last Post: 02-26-2019, 11:33 PM
  3. [SOLVED] Improve UDF speed
    By pdauction in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-07-2018, 05:51 AM
  4. [SOLVED] Need improve macro speed
    By Remphan in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 12-29-2015, 10:43 AM
  5. Improve Calculations Speed
    By samcdavies in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-21-2015, 09:14 PM
  6. [SOLVED] Need assistance to improve speed in looking up value
    By a_driga in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-29-2015, 08:37 PM
  7. How to improve web query speed
    By hegisin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-18-2007, 12:40 AM

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