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!!
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