Row Delete taking time

  • Thread starter Thread starter sapna
  • Start date Start date
S

sapna

Hi ...

I am very new to writing macros in excel.Though I have found it simpl
there are things that I am getting stuck at.

I have written a code for Deleting of a row for a certain condition bu
whenever I run the particular macro the execution takes a lot of tim
....

I have abot 300 rows in my spreadsheet .... and the code is

For R = Rng.Rows.Count To 1 Step -1
If Application.WorksheetFunction.CountA(Rng.Rows(R).EntireRow) =
Then
Rng.Rows(R).EntireRow.Delete
ElseIf Cells(R, 2).Value = "deleted" Then
Rows(R).Delete
ElseIf Cells(R, 2).Value = "" Then
Rows(R).Delete
ElseIf Cells(R, 2).Value = Null Then
Rows(R).Delete
End If

Next R



Is there a solution to getting around the problem.

Thanking in advance
Sap.
 
Hi
maybe your used range is larger than just 300 rows. There did you get
if hitting CTRL+END in your worksheet?
 
Hi,


No Frank I have checked the range it is 300 ... what I understand i
that there is an issue with the code becoz as I read values and the
check for the specific condition it goes slower... the same code work
fine (gets excuted fast ) if I leave only 45 rows in my spreadsheet b
deleting the rest


Sap.
 
Hi
try

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For R = Rng.Rows.Count To 1 Step -1
If Application.WorksheetFunction.CountA(Rng.Rows(R).EntireRow) = 0
Then
Rng.Rows(R).EntireRow.Delete
ElseIf Cells(R, 2).Value = "deleted" Then
Rows(R).Delete
ElseIf Cells(R, 2).Value = "" Then
Rows(R).Delete
ElseIf Cells(R, 2).Value = Null Then
Rows(R).Delete
End If
Next R
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top