+ Reply to Thread
Results 1 to 7 of 7

macro takes forever to complete

Hybrid View

  1. #1
    Registered User
    Join Date
    08-15-2023
    Location
    Zakynthos Greece
    MS-Off Ver
    office 2021
    Posts
    3

    Exclamation macro takes forever to complete

    I use this macro to hide older than today rows.
    The problem is that it runs for the already hidden rows and thus it takes forever to complete
    because there are more than 1500 rows in the table...
    ver
    office 2019 and office 2021

    Any ideas??
    --------------------------------------
    Sub HIDE_OLDER()
    Dim i As Long
    Dim TODAY As Date
    Sheets("LOG").Activate
    For i = ActiveSheet.UsedRange.Rows.Count To 3 Step -1
    Range("b" & i).Select
    If ActiveCell.Value < Date Then
    ActiveCell.EntireRow.Hidden = True
    Else
    End If
    Next i
    End Sub
    Last edited by AliGW; 08-15-2023 at 06:41 AM. Reason: Code tags added - please review the forum rules.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2407 (Windows 11 23H2 64-bit)
    Posts
    82,883

    Re: macro takes forever to complete

    Welcome to the forum.

    Please review the forum rules on code tags. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    O365 32bit (Windows)
    Posts
    2,085

    Re: macro takes forever to complete

    Try

    Sub test()
    Dim i As Long
    Application.ScreenUpdating = False
    With Sheets("LOG")
        For i = .Cells(Rows.Count, "B").End(xlUp).Row To 3 Step -1
            With .Cells(i, "B")
                If .EntireRow.Hidden = False Then .EntireRow.Hidden = .Value < Date
            End With
        Next i
    End With
    Application.ScreenUpdating = True
    End Sub

  4. #4
    Registered User
    Join Date
    08-15-2023
    Location
    Zakynthos Greece
    MS-Off Ver
    office 2021
    Posts
    3

    Re: macro takes forever to complete

    Aha !
    This one worked just fine. Thank you!
    If I unhide all rows and run it it still takes long time to complete.
    But if rows are hidden and needs to hide 10 more (from yesterday)
    it works perfect.
    So, Thank you again
    Pete

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: macro takes forever to complete


    As a reminder filtering data just replaces the useless slow loop …

  6. #6
    Registered User
    Join Date
    08-15-2023
    Location
    Zakynthos Greece
    MS-Off Ver
    office 2021
    Posts
    3

    Re: macro takes forever to complete

    Quote Originally Posted by Marc L View Post

    As a reminder filtering data just replaces the useless slow loop …
    I agree but
    saving a filter as macro to be attached to a button
    is not my expertise yet :-)

    I use filters else were in my sheets but I don't know how to do this one.

    Thanks !

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: macro takes forever to complete


    So easy to start yourself just activating the Macro Recorder and operating manually …
    For more help attach at least a workbook.

+ 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] Creating a macro to replace a formula that takes forever to calculate
    By PaulM100 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-03-2018, 09:49 AM
  2. [SOLVED] InStr macro takes forever.
    By taylorsm in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-06-2017, 10:40 AM
  3. [SOLVED] Step within Macro is taking forever to complete and locks up excel until complete
    By cubangt in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 05-16-2017, 11:58 AM
  4. Macro takes forever after upgrading from excel 20007 to 2010
    By Yigal in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-05-2014, 10:45 AM
  5. Macro Takes forever To Execute
    By daveyc18 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-16-2014, 11:14 AM
  6. Replies: 7
    Last Post: 12-19-2008, 10:57 PM
  7. hiding a few rows with a macro takes forever
    By Conor in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-09-2007, 06:34 PM

Tags for this Thread

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