+ Reply to Thread
Results 1 to 3 of 3

Problems with slow code, can this be coded differently to speed it up.

  1. #1
    Registered User
    Join Date
    10-14-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    82

    Problems with slow code, can this be coded differently to speed it up.

    Hi

    I have a small project that i am developing and its coming along OK. The problem I have is the clunky code I think, it takes to long to populate, its not too bad on my i7 processor but when I move it to my tablet its not quick enough.

    I will explain the purpose of the application.

    I have a sheet that holds all the data called "MatsData" and a userform called "frmcontract"

    There are two listboxes "Listbox1" & "Listbox2" The category name from cell "C" in "MatsData" populates into the "Listbox1" whichever category that is chosen in "Listbox1" is transferred to "Listbox2". When you have completed choosing the categories you hit the + button to create the document; this is where it slows up, I know the code looks complex and it does for me. I had this code written by a friend and he is unavailable to help, I cannot work it out due to my limitations I am relatively new to vba and only pick things up from you good guys, I would appreciate if someone could shed some light on this. I have attached the file.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Problems with slow code, can this be coded differently to speed it up.

    Hi,

    First things first. Are you sure that VBA is the most efficient way of doing this. I don't believe it is. Only resort to VBA when standard functionality won't give you what you want. And even if you do need VBA avoid loops wherever possible. This is often the case when loops are merely extracting information after evaluating each cell in a range. This can usually be avoided by using a Data Filter to identify all such cells in one hit.

    Your macro is doing a lot of formatting and also a lot of looping. Formatting with VBA could probably be avoided by using conditional formatting and looping could probably be avoided by using filtering.

    The essence of what you're doing is picking items from the MatsData sheet. Why not use standard excel functionality with say a validation drop down Yes/No cell, or mark each row you want to use. Then just use VBA to extract those items to your Materials and Workmanship sheet.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    10-14-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    82

    Re: Problems with slow code, can this be coded differently to speed it up.

    Hi Richard

    Thanks for your reply; the simple answer is that i really do not know where to start with your suggestions. I know this might be cheeky but could you do a very small sample to show me what you mean.

    thanks again

+ 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. Username Code help - Slow processing speed
    By JBurton1986 in forum Excel General
    Replies: 6
    Last Post: 02-21-2014, 06:53 AM
  2. [SOLVED] Slow VBA Code for simple Loop and add pasted values Any Way to Speed Up
    By John Vieren in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-10-2013, 11:16 AM
  3. [SOLVED] VBA - Full Speed Code Problems
    By Neutralizer in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-16-2013, 06:11 AM
  4. Combing data coded differently
    By mikebravo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-21-2012, 06:26 PM
  5. How can I speed up this slow macro?
    By rs2k in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-18-2008, 08: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