+ Reply to Thread
Results 1 to 10 of 10

Code running really slowly

Hybrid View

  1. #1
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: Code running really slowly

    Sorry - missed an end if:
    Sub Caseware()
    Dim rngtodelete as range
    Application.ScreenUpdating = False
    Application.Calculation = xlManual
    Dim i As Long
    
    For i = Cells(Rows.Count, "a").End(xlUp).Row To 2 Step -1
    If Cells(i, "e") = 0 Then
    If rngtodelete is nothing then
    Set rngtodelete = cells(I, " e")
    Else 
    Set rngtodelete = union(rngtodelete, cells(I, "e"))
    End if
    End if
    Next i
    If not rngtodelete is nothing then rngtodelete.entirerow.delete
    End Sub
    Everyone who confuses correlation and causation ends up dead.

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,726

    Re: Code running really slowly

    Just thinking out loud here.
    Would this work?
    Sub Try()
        With Range("E1:E8000")    '<---- Change as required
            .Replace 0, "", xlWhole
            .SpecialCells(4).EntireRow.Delete
        End With
    End Sub

  3. #3
    Forum Contributor
    Join Date
    02-24-2010
    Location
    BC, Canada
    MS-Off Ver
    Excel 2010
    Posts
    174

    Re: Code running really slowly

    Quote Originally Posted by jolivanes View Post
    Just thinking out loud here.
    Would this work?
    Sub Try()
        With Range("E1:E8000")    '<---- Change as required
            .Replace 0, "", xlWhole
            .SpecialCells(4).EntireRow.Delete
        End With
    End Sub
    I tried this on a sample sheet with 16 rows, 4 of which should have been deleted. It worked but it took over 30 seconds to run.

    It's looks like there's something wrong with the workbook itself. If I make a new workbook and run your script, then it works pretty much instantly....

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,726

    Re: Code running really slowly

    What kind of formulae do you have in the workbook?
    I had a similar problem years ago. Some functions recalculate whenever a change is made.
    I changed the culprits and the problem was solved.
    I personally don't know anything at all about these functions but if you post the formulae someone might be able to give you an alternative.

  5. #5
    Forum Contributor
    Join Date
    02-24-2010
    Location
    BC, Canada
    MS-Off Ver
    Excel 2010
    Posts
    174

    Re: Code running really slowly

    Quote Originally Posted by romperstomper View Post
    Sorry - missed an end if:
    I should have mentioned this, I tried adding an end if because I saw that too, but then I get the following error:

    Run-time error '13':
    Type mismatch

+ 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] Code running slowly
    By Sweepin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-30-2013, 09:15 PM
  2. [SOLVED] Code running slowly any way of speeding up processing time
    By boomboomblock in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-02-2013, 09:09 AM
  3. Code running slowly
    By rhudgins in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 02-01-2011, 11:08 AM
  4. Replies: 3
    Last Post: 11-24-2010, 03:43 AM
  5. Paste code running extremely slowly...
    By KR in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-03-2005, 11:05 AM

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