nitrammada
Board Regular
- Joined
- Oct 10, 2018
- Messages
- 78
- Office Version
- 365
- Platform
- Windows
Hi Everyone,
I have a macro that clears the row from columns C to P if the cell in column C = 0.
Once the cell in column C is found to contain 0, everything below (including that row) can be cleared in columns C to P.
The macro works but it takes such a long time eg 30 seconds to clear 1500 rows.
Is there a quicker way to do this? Below is what I have already.
I have had a look on the forum questions (a big thanks for all those that contribute) but most solutions use the 'Loop' function and it takes ages to clear.
Any suggestions would be most welcome, or perhaps I have something in my code that is slowing it down.
Thanks in advance
Adam
I have a macro that clears the row from columns C to P if the cell in column C = 0.
Once the cell in column C is found to contain 0, everything below (including that row) can be cleared in columns C to P.
The macro works but it takes such a long time eg 30 seconds to clear 1500 rows.
Is there a quicker way to do this? Below is what I have already.
VBA Code:
Sub ClearErrors()
'This is for sheet "Print3" to remove the #N/A at bottom of report
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim Count, i As Long
Count = ActiveSheet.Cells(Rows.Count, "j").End(xlUp).Row
'MsgBox count
i = 8
Do While i <= Count
If Cells(i, 3) = 0 Then
Rows(i).EntireRow.ClearContents
'Range(Cells(i, 3), Cells(i, 16)) = ""
End If
i = i + 1
Loop
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
I have had a look on the forum questions (a big thanks for all those that contribute) but most solutions use the 'Loop' function and it takes ages to clear.
Any suggestions would be most welcome, or perhaps I have something in my code that is slowing it down.
Thanks in advance
Adam