Macro causing Workbook to slow down and freeze

jamesdean1379

New Member
Joined
Jun 11, 2014
Messages
49
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
 

Forum statistics

Threads
1,082,131
Messages
5,363,337
Members
400,726
Latest member
Shahzad Taimoor

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top