+ Reply to Thread
Results 1 to 4 of 4

making code more efficient

  1. #1
    Forum Contributor
    Join Date
    06-25-2007
    Posts
    166

    making code more efficient

    I started building a large template in excel several months ago when I was very new to VBA. Since then, I've started to pay more attention to making my macros more efficient, so I'm currently going over my old code and trying to rework it to make the whole file smaller and quicker.

    My question is if I have a small block of code with only a couple lines like this:
    Please Login or Register  to view this content.
    is it any more or less efficient to write it like this:
    Please Login or Register  to view this content.
    Of course, I understand that the difference may be negligible for one small block of code, but if I have 50-100 similar to this throughout my workbook, is it worth it to go change them all?

    Thank you,
    JCC

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    I would say it's just make the code easier to read

    Also you should avoid selecting plus you could change

    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    In VB editor. Press ctrl + H and find enter
    Please Login or Register  to view this content.
    and replace enter
    Please Login or Register  to view this content.
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Contributor
    Join Date
    06-25-2007
    Posts
    166
    That's great. Thanks for the suggestions - I'll make those changes.

    Two more related questions:

    1. Is "Application." necessary when writing a block like:
    Please Login or Register  to view this content.
    When is that needed and when is it not? What purpose does it serve?

    2. Why is ".Value" preferred over ".FormulaR1C1"? I'm certainly not doubting you... just curious.

    Thanks again

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    No

    Application examples would be like

    Please Login or Register  to view this content.
    Can also use it for a sheet e.g

    Please Login or Register  to view this content.
    So shorter to type (more so with longer code) and easier to read

    VBA Noob

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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