+ Reply to Thread
Results 1 to 7 of 7

Code better or faster?

  1. #1
    Forum Contributor
    Join Date
    01-29-2019
    Location
    Drenthe, Netherlands
    MS-Off Ver
    Dutch Office 2019
    Posts
    291

    Code better or faster?

    I wrote my own script. It works like a charm. My question you think?

    Can it be cleaner, better or faster!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Code better or faster?

    It certainly looks like a reasonable bit of code and unless it is in some sort of loop where it gets executed thousands of times, my suggestions won't save any noticeable amount of time, but here they are nonetheless.

    First is to set a pointer to the sheets instead of using the sheet names themselves.

    Please Login or Register  to view this content.
    I do not know if this saves any time in code execution, but it does save typing and it does declutter the code. Also once set, the pointer remembers what workbook it belongs to, so if you have other workbooks open, you don't have to worry if sh is in the active workbook.

    The other thing is that I don't like to do the same calculation more than once whether it be in code or in a formula on a worksheet. What I suggest as cleanup is
    Please Login or Register  to view this content.
    As I mentioned above, this probably won't matter unless you are doing it a thousand or so times.

    At least it looks cleaner.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Contributor
    Join Date
    01-29-2019
    Location
    Drenthe, Netherlands
    MS-Off Ver
    Dutch Office 2019
    Posts
    291

    Re: Code better or faster?

    dflak,

    Thanks for the reply. I changed it to
    Please Login or Register  to view this content.
    Is there a faster wat to unlock en lock several sheet i call in the macro.

    Please Login or Register  to view this content.
    Last edited by jeffreybrown; 02-12-2019 at 08:57 PM. Reason: Removed full quote!

  4. #4
    Forum Contributor
    Join Date
    01-29-2019
    Location
    Drenthe, Netherlands
    MS-Off Ver
    Dutch Office 2019
    Posts
    291

    Re: Code better or faster?

    Found a script that run all sheets to protect and unprotect.
    This is the macro now. Thanks all.



    Please Login or Register  to view this content.

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Code better or faster?


  6. #6
    Forum Contributor
    Join Date
    01-29-2019
    Location
    Drenthe, Netherlands
    MS-Off Ver
    Dutch Office 2019
    Posts
    291

    Re: Code better or faster?

    That helpt a lot! Smoother and more protected.

    3 week ago i didn't now what a macro or what VBA was. Nice dudes!!

  7. #7
    Forum Contributor
    Join Date
    01-29-2019
    Location
    Drenthe, Netherlands
    MS-Off Ver
    Dutch Office 2019
    Posts
    291

    Re: Code better or faster?

    Please Login or Register  to view this content.

+ 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] Faster Code ?
    By colddeck84 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2017, 01:34 PM
  2. [SOLVED] Run the code faster.
    By countryfan_nt in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-29-2017, 05:03 AM
  3. [SOLVED] Trying to get this code to run FASTER
    By g1terra in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-28-2017, 02:23 PM
  4. vba code to run faster
    By ikhan99 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-22-2016, 02:19 AM
  5. [SOLVED] Get a code to run faster
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-04-2015, 02:07 AM
  6. I need faster code
    By mpeplow in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-16-2007, 05:30 PM
  7. [SOLVED] Faster way to code this
    By jhahes in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-06-2006, 12:08 PM

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