Macro causing Workbook to slow down and freeze

jamesdean1379

Board Regular
Joined
Jun 11, 2014
Messages
55
Hey guys,

I am using the below macro and whenever i try to delete or add a row or column it takes longer than normal, like it is having to think about it, and when I run the macro the entire workbook freezes and after waiting 5+ mins i have to force close excel. Now the workbook I am using has 2 macros saved to it and has formulas and saved as ".xlsm". I do not believe formulas to be the issue and i have copied the macro i believe to be the problem below.

What this macro is supposed, or trying, to do is pull information from "Dwelling" to "Departed" if column "O" formula in "Dwelling" equals False. If it is false it is supposed to copy the entire row over to "Departed" on the next available row. And since i have formulas in columns A and O all the way down the worksheet it is supposed to stop once cell in column B is blank.

Any help you guys can provide is appreciated!!

Code:
Sub MACRO()

ActiveSheet.Unprotect "ETNDWELL"
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Dim lr As Long, c As Long
lr = Range("A" & Rows.Count).End(xlUp).Row
For c = 2 To lr
    If Range("O" & c).Value = False Then Rows(c).copy Destination:=Sheets("DEPARTED").Range("A" & Rows.Count).End(xlUp).Offset(1)
Next c

Dim lastRow As Long
    Dim i As Long
    Dim firstRow As Long
     
     
     'First row to look at?
    firstRow = 1
     
     
    Application.ScreenUpdating = False
    With Worksheets("DWELLING")
         'Find the first blank cell
        lastRow = .Range("B1").End(xlDown).Row
         
         'Safety check
        If lastRow > 10000 Then
            If MsgBox("Over 10k rows found. Still proceed?", vbYesNo + vbDefaultButton2) <> vbYes Then
                Exit Sub
            End If
        End If
         
         'Begin loop
        For i = lastRow To firstRow Step -1
             'Check if we should delete row
            If .Cells(i, "O").Value = False Then
                .Cells(i, 1).EntireRow.DELETE
            End If
        Next i
    End With
    Application.ScreenUpdating = True

Application.ScreenUpdating = True
Apllication.Calculation = xlCalulationAutomatic
ActiveSheet.Protect "ETNDWELL"
     
End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Forum statistics

Threads
1,214,626
Messages
6,120,602
Members
448,974
Latest member
ChristineC

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top