+ Reply to Thread
Results 1 to 6 of 6

Very slow macro

  1. #1
    Registered User
    Join Date
    01-01-2010
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    34

    Very slow macro

    Sorry, but another question about slow macro's. I've read a lot of threads about it but cannot figure out what I'm doing wrong here.

    This macro will check a large cost estimate for empty line items. If no quantity is calculated, the line item is hidden. Also if a heading has no line items at all, the heading (incl. subtotal) is hidden as well. So far, this works. However if a cost estimate has several hundred line items and a couple of dozen objects (worksheets) it takes a very long time.

    Maybe somebody has some advice to improve this macro? Maybe the 'case' statement instead of 'if end if'?

    Please Login or Register  to view this content.
    The code with ?????0 knows what a line item is. They always have 6 digits and a zero at the end.

    Thank you in advance.
    Erik
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Very slow macro

    maybe
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Very slow macro

    hi ESF, please check attachment, run code "test". The code has been modified completely.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by watersev; 09-05-2012 at 04:33 AM. Reason: code runs on one sheet only

  4. #4
    Registered User
    Join Date
    01-01-2010
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    34

    Re: Very slow macro

    Wow! This a huge time saving for both suggestions! Initially I had to wait many many minutes. Now for the code by watersev 1,5 minute and JosephP to 11 seconds!

    Please Login or Register  to view this content.
    As I try to understand both your improvements, I see you skip the hiding part till the end and then use 'union' to hide them all in once. The code by watersev is doing perfect, however for more time saving I tried to fix JP’s code.

    Unfortunately one row is not hidden by mistake (see screendump). If a heading has no line items underneath, its sub-total is hidden (correctly) but the heading itself not. I think this is checked in this part:

    Please Login or Register  to view this content.
    but I don't know how to correct it.
    Attached Images Attached Images

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Very slow macro

    my bad
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    01-01-2010
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    34

    Re: Very slow macro

    Perfect! I'll turn this thread into 'solved'.

    Thank you all

+ 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