+ Reply to Thread
Results 1 to 4 of 4

Improve VBA code to be more efficient, less long and use less memory

  1. #1
    Registered User
    Join Date
    08-09-2017
    Location
    Indiana
    MS-Off Ver
    Execl 2013, Windows 10
    Posts
    23

    Improve VBA code to be more efficient, less long and use less memory

    I am new to VBA and not a programmer. I know what I did is NOT EFFICIENT. But for the most part it is working. To do this I copied macros and made adjustments.

    Need to Copy 13 individual workbooks (each with 8000-15000 rows) into a single workbook . Then to each of the 13 sheets, added 4 columns, labels, formulas to the new columns all the cells used in other rows with values. Did some sorting and removing of duplicates on a few of the columns.

    Got error that procedure was too large, so I cut it in about half. Then got insufficient memory - so I'm not getting memory released in doing this.

    Can anyone help me make improvements to this?

    I've attached two sample spreadsheets (there are 13 of them in total) I cut off the below code to not show all since it is just a copy/paste with change of sheet name.



    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: Improve VBA code to be more efficient, less long and use less memory

    Maybe for the first part (combining the sheets) you can just do this

    Please Login or Register  to view this content.
    If you want something done right... find a forum and ask an online expert.

    Time flies like an arrow. Fruit flies like a banana.

  3. #3
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: Improve VBA code to be more efficient, less long and use less memory

    I would either leave all coding of the format till the end or do it in a template in the sheet.
    If you do it in the sheet you don't need to know the coding in vba to update it as needed and if you do it in the coding at the end it will be easy to find and edit without having to worry about how all your other actions effect the format.
    Anyway in that spirit find the attached.

    Have a look to see if you need add any further formatting at the end.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Improve VBA code to be more efficient, less long and use less memory

    Take a look, the main stem of your macro I kept.
    But since I don't have a new excel, I have replaced some of the features.
    Your code vba for 'RemoveDuplicates' and 'SortFields' was commented / blocked.
    Check how it works in my version and how it is in your version - after the change of comment/blocking.
    Attached Files Attached Files

+ 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] Thrashing VBA Memory Leaks. Memory Loop Problems. Uncleared Memory in .Match Range Object
    By Doc.AElstein in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-10-2017, 05:17 PM
  2. Worksheet calculations very slow...how to improve and/or make efficient
    By skyping in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-14-2016, 05:20 AM
  3. [SOLVED] Long VBA Code - Improve Efficiency?
    By Dgp2012 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-18-2013, 11:29 AM
  4. Most efficient way to script to automate a long process?
    By Arcaklar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-21-2013, 11:55 PM
  5. [SOLVED] To improve Efficiency of code, code running too long
    By andywsw in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-19-2012, 05:54 PM
  6. Remove long running loop with someting more efficient
    By JP Romano in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-10-2009, 02:20 PM
  7. Looking for a more memory-efficient way
    By geoffjb in forum Excel General
    Replies: 9
    Last Post: 04-03-2009, 04:34 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