want to delet greater than 3, loop not wroking taking long time

husayn

New Member
Joined
Dec 8, 2015
Messages
41
I WANT TO DELET >3, IF IN COLUM C NUMBER IS GREATER THAN 3 THAN DELET THAT ROW, MY DATA IS AROUND 45-50 THOUSAND IT MAY CONATINS -7000,-5000,5000,6000,5,4. BUT I WANT TO DELET ONLY THE ROW WHICH IS GREATER THAN (>)3.

<colgroup><col width="227"></colgroup><tbody>
</tbody>
LOOPING IS TAKING VERY LONG TIME NEED SUGGESTION.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Try this:
Code:
Sub Auto_Filter_New()
'Modified 10-24-17 5:20 AM EDT
Application.ScreenUpdating = False
If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False
    With Range("C1:C" & Cells(Rows.Count, "C").End(xlUp).Row)
        .AutoFilter Field:=1, Criteria1:=">3"
        
        .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow.Delete
      .AutoFilter
    End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0
It may help to give an answer if you could you post the code that you are using, please.

Dim LR As Long
Dim i As Long
Dim c As Range
LR = Cells(Rows.Count, 3).End(xlUp).Row
For i = LR To 1 Step -1
Set c = Range("C" & i)
If Right(c, 2) > 3 Then c.EntireRow.Delete
Next i
 
Upvote 0
My script looks for number >3

Not sure what this means:
IT MAY CONATINS -7000,-5000,5000,6000,5,4.
 
Upvote 0
Try this:
Code:
Sub Auto_Filter_New()
'Modified 10-24-17 5:20 AM EDT
Application.ScreenUpdating = False
If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False
    With Range("C1:C" & Cells(Rows.Count, "C").End(xlUp).Row)
        .AutoFilter Field:=1, Criteria1:=">3"
        
        .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow.Delete
      .AutoFilter
    End With
Application.ScreenUpdating = True
End Sub

thanku very much YES THIS IS WORKING its taking only few second to delet 50,000 rows. once again thanku very much
 
Upvote 0
Glad I was able to help you.
Come back here to Mr. Excel next time you need additional assistance.
thanku very much YES THIS IS WORKING its taking only few second to delet 50,000 rows. once again thanku very much
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,638
Members
449,093
Latest member
Ahmad123098

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