+ Reply to Thread
Results 1 to 12 of 12

Slow Macro ? - Need Assistance in Optimizing Code

  1. #1
    Registered User
    Join Date
    06-10-2010
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    12

    Slow Macro ? - Need Assistance in Optimizing Code

    I posted a thread a few weeks ago and received great advice, so I am back! To give you some background information I will explain the instructions:

    The worksheet contains information that is seperated by section headings. I have created a form that collects information and inserts into the appropriate section. A listbox value (Heading Name) determines the section placement of the information. I have created a loop that searches for these section headings. It then inserts a new row with the new information. Several formatting changes also take place during the process.

    The code works correctly except for the 10 second pause after you click the submit button. The 10 second delay eliminates the benefit of the form/macro. I am new to VBA coding so don't be alarmed if the code is poorly written.

    Thanks a lot in advance!


    Please Login or Register  to view this content.
    Last edited by robby10; 07-08-2010 at 09:05 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Slow Macro ? - Need Assistance in Optimizing Code

    Don't slect or activate. Don't Looop unless necessary, in your code use .Find to find the text
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    06-10-2010
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Slow Macro ? - Need Assistance in Optimizing Code

    Could you get me started on the alternative code? Those are the only ways I know how to execute the code. Thanks!

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Slow Macro ? - Need Assistance in Optimizing Code

    You haven't declared variables.

    I would rather see what the code is supposed to do than work through all this. Can you attach the workbook

  5. #5
    Registered User
    Join Date
    06-10-2010
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Slow Macro ? - Need Assistance in Optimizing Code

    Here is the workbook..

    Thanks!
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    06-10-2010
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Slow Macro ? - Need Assistance in Optimizing Code

    Is anyone able to comment on this?

    Thanks!

  7. #7
    Registered User
    Join Date
    06-10-2010
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Slow Macro ? - Need Assistance in Optimizing Code

    I have done a little research but I haven't been able to get the .find function to work.. It errors out saying runtime error 1004 application-defined or object defined error. I have tried to change up the find settings but nothing seems to work. Any ideas? Thanks!!

    Please Login or Register  to view this content.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Slow Macro ? - Need Assistance in Optimizing Code

    I did say avoid selecting and what is the expected result?

    Your code is looking for xSubmit, is this a variable?

  9. #9
    Registered User
    Join Date
    06-10-2010
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Slow Macro ? - Need Assistance in Optimizing Code

    Sorry, I changed the variable xSubmit to tHeading and forgot to reflect the change in the post. I also eliminated the select command. It is still faultering on the .find command.

    The expected result can be found in the workbook. That is with the very slow code that includes selecting and loops. I removed some of the code in my last post to focus on the .find command for present discussion.

    Thanks Roy!
    Last edited by robby10; 07-12-2010 at 10:09 AM.

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Slow Macro ? - Need Assistance in Optimizing Code

    sEE IF THIS WORKS
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    06-10-2010
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Slow Macro ? - Need Assistance in Optimizing Code

    I had to add an End With at the end of that code. The same 1004 error is coming up for the .find command.

    I'll post all of the code for your reference.

    Thanks again!

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    06-10-2010
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Slow Macro ? - Need Assistance in Optimizing Code

    I changed the columns to range and that fixed the 1004 error issue but now it is saying object required? I looked through excel help but haven't figured anything out..

    Thanks

+ 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