Results 1 to 6 of 6

Speeding Up Code

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Speeding Up Code

    Hi. I have the following code but it runs rather slow as there is about 1500 rows. Any idea how to speed it up? Macro looks at sheet F and sheet CG and if a certain few cells exists already in sheet CG that is in sheet F, then this deletes the row from sheet F

    Sub Remy()
    
        Dim rsht1 As Long, rsht2 As Long
        
        rsht1 = Sheets("F").Range("B" & Rows.Count).End(xlUp).Row
        rsht2 = Sheets("CG").Range("B" & Rows.Count).End(xlUp).Row
        
        For i = 1 To rsht1
            For j = 1 To rsht2
                If Sheets("F").Range("B" & i) = Sheets("CG").Range("B" & j) And Sheets("F").Range("C" & i) = Sheets("CG").Range("C" & j) _
                And Sheets("F").Range("D" & i) = Sheets("CG").Range("D" & j) _
                And Sheets("F").Range("F" & i) = Sheets("CG").Range("F" & j) Then
                    Sheets("F").Rows(i).Select
                    Selection.Delete Shift:=xlUp
                End If
            Next
        Next
    
    End Sub
    Last edited by ScabbyDog; 03-25-2013 at 11:52 AM.

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