+ Reply to Thread
Results 1 to 18 of 18

Stop macro at the end of data / make macro faster

  1. #1
    Registered User
    Join Date
    07-21-2010
    Location
    Largo, FL
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    54

    Question Stop macro at the end of data / make macro faster

    I have 5 macro's that I use everyday, multiple times a day. Thanks to this site, I am now able to run one macro to run all of them. Before, I ran each macro separately.

    There were 2-3 other people involved in making these macros. I have managed them and keep adding "rules" to them.

    Can you all take a look at the macros and help me with ideas on making the macros run faster? Also, I use 2007, but get 2003 sheets. I may get files with 100 rows and the next file will have 300,000 rows. The problem is the macro runs to the last row....65,536. It does not stop at last row with data. There is a code someone added to column B that could be deleted if I can get the the macro to stop at the end of the data.

    Macro E are F and basically the same, but F is customer specific.

    Thanks in advance for any help.

    PS - I only put the codes in the attached worksheet to show you all what the functions are and the order they run in. Below this post, I have attached a typical worksheet that I work with.
    Attached Files Attached Files
    Last edited by Shaner73; 08-13-2010 at 11:15 AM. Reason: Spelling error and added description to problem

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,372

    Re: Stop macro at the end of data / make macro faster

    Try this:-- Add ScreenUpdating statements to your Macro A

    Please Login or Register  to view this content.
    This should make your code run much faster.

  3. #3
    Registered User
    Join Date
    07-21-2010
    Location
    Largo, FL
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    54

    Re: Stop macro at the end of data / make macro faster

    MarvinP - Thanks for the code, but it really isn't any faster. And it still goes all the way down to 65K+ rows.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,372

    Re: Stop macro at the end of data / make macro faster

    I have to ask..
    Your macros are on a worksheet in your attached file.
    Tell me that you have them in a Module and are running them from there!

    It would be easier with an example file where the macros were in the module. Some sample data would also be helpful.

  5. #5
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Stop macro at the end of data / make macro faster

    How are you getting to the end of the line?
    This is what I just did now:

    Please Login or Register  to view this content.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Stop macro at the end of data / make macro faster

    or
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    07-21-2010
    Location
    Largo, FL
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    54

    Re: Stop macro at the end of data / make macro faster

    Quote Originally Posted by MarvinP View Post
    I have to ask..
    Your macros are on a worksheet in your attached file.
    Tell me that you have them in a Module and are running them from there!

    It would be easier with an example file where the macros were in the module. Some sample data would also be helpful.
    I put the macros in a spread sheet so I could compare and organize them. I do not run them from that sheet. have them located in my Personal file and then hidden.

    Let me see if I can up load a file I typically work on.....

    Ok, I have attached an edited file for you to work with.
    Attached Files Attached Files

  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: Stop macro at the end of data / make macro faster

    Why have you posted a workbook with the code typed into a sheet/

    If that's the code you are using then it would rumn more efficiently if you didn't select the ranges, etc
    Hope that helps.

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

    Free DataBaseForm example

  9. #9
    Registered User
    Join Date
    07-21-2010
    Location
    Largo, FL
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    54

    Re: Stop macro at the end of data / make macro faster

    Quote Originally Posted by royUK View Post
    Why have you posted a workbook with the code typed into a sheet/

    If that's the code you are using then it would rumn more efficiently if you didn't select the ranges, etc
    I figured it would be easier to put them in a workbook and post that due to the number of macro's I use. Otherwise I would have multiple posts with different codes.

    Can you explain what you mean by "if you didn't select the ranges, etc"?

    I'm fairly new to all of this.

  10. #10
    Registered User
    Join Date
    07-21-2010
    Location
    Largo, FL
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    54

    Re: Stop macro at the end of data / make macro faster

    Bump for any other advice.

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

    Re: Stop macro at the end of data / make macro faster

    Selecting ranges, cells etc like you seem to do will slow code down considerable. A simple example
    Please Login or Register  to view this content.
    Application.ScreenUpdating will stop the screen refreshing as the code selects & speed up somewhat, but not actually selecting ranges will speed the code up dramatically up

    It's much easier for us to see the code & edit it in the VB Editor

  12. #12
    Registered User
    Join Date
    07-21-2010
    Location
    Largo, FL
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    54

    Re: Stop macro at the end of data / make macro faster

    Ok, I think I'm starting to understand this a little better.

    Here are the codes in order...I put them in separate posts and have shortened them to save space.

    First:

    Please Login or Register  to view this content.
    Last edited by Shaner73; 08-16-2010 at 08:31 AM.

  13. #13
    Registered User
    Join Date
    07-21-2010
    Location
    Largo, FL
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    54

    Re: Stop macro at the end of data / make macro faster

    Second:

    Please Login or Register  to view this content.
    code continued... ---->

  14. #14
    Registered User
    Join Date
    07-21-2010
    Location
    Largo, FL
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    54

    Re: Stop macro at the end of data / make macro faster

    Second continued....

    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    07-21-2010
    Location
    Largo, FL
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    54

    Re: Stop macro at the end of data / make macro faster

    The second, third and fourth codes are pretty much the same.

    Fifth....

    Please Login or Register  to view this content.

  16. #16
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Stop macro at the end of data / make macro faster

    Sub A rewritten:

    Please Login or Register  to view this content.
    Because you told us that your code isn't in any of the activeworkbook's modules, you have to specify which workbook and which worksheet the code has to apply to.

  17. #17
    Registered User
    Join Date
    07-21-2010
    Location
    Largo, FL
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    54

    Re: Stop macro at the end of data / make macro faster

    I attached a worksheet that I work with on Page 1 of this thread. I have 9 Modules, but I use the first 5 several times a day. Macro A really isn't slow enough for me to worry about. It's Macro's B-E that are slow.

    Since the macro was written by two other people, they use the "Selection". If "Range" will be faster, how do I edit the code? Also, will that stop at the last row of data. I am currently working on a spreadsheet that has 58,906 rows, but the macro worked down to row 1,048,576. I know that takes extra time, but I'm not sure what to change the code to.

    I also added approx. 50 "rules" to A Macro this morning. So to write out the code above snb wrote, I think that would take me forever to change.

    I really appreciate the help!!

    Shane
    Last edited by Shaner73; 08-16-2010 at 04:00 PM.

  18. #18
    Registered User
    Join Date
    07-21-2010
    Location
    Largo, FL
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    54

    Re: Stop macro at the end of data / make macro faster

    Please close this thread due to no more responses. For me, the problem was not solved.

    I will be trying another site for help on this particular issue.

    Thank you anyway.

+ 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