Deleting rows that dont fit criteria
I guess the following would be a little faster...
Sub DeleteNon00Rows()
Dim X As Long
Dim LastRow As Long
Application.ScreenUpdating = False
Application.Calculation = xlManual
With Worksheets("Sheet2")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For X = LastRow To 1 Step -1
If Not .Cells(X, "A").Value Like "*00" Then Rows(X).Delete
Next
End With
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub
--
Rick (MVP - Excel)
"Rick Rothstein" wrote in message
...
Give this macro a try...
Sub DeleteNon00Rows()
Dim X As Long
Dim LastRow As Long
With Worksheets("Sheet2")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For X = LastRow To 1 Step -1
If Not .Cells(X, "A").Value Like "*00" Then Rows(X).Delete
Next
End With
End Sub
Note that I started with the (calculated) last row and worked the loop
backwards... if you loop forward, each deleted row screws up what the loop
counter is counting.
--
Rick (MVP - Excel)
"Cuervogold" wrote in message
...
I am new to the Excel macro language, and I am trying to delete entire
rows from 10000+ data points if the last two digits of a 12-digit
number in column A do not end in 00. Here is the macro I have, but it
will only delete the cell in column A. Again, I have an entire
worksheet with corresponding data that needs to be deleted. Thanks
============================
Sub Delete_numbers()
Dim i As Long
Dim number As string
Dim last2 As string
i = 1
number = ActiveCell.FormulaR1C1
For i = 1 to 1000000
number = ActiveCell.FormulaR1C1
If Not number = "" Then
last2 = Right(number, 2)
If Not last2 = "00" Then
Selection.Delete Shift:=xlUp
Else
ActiveCell.Offset(1, 0).Range("A1").Select
End If
Else
Exit For
End If
Next i
End Sub
|