slamet Harto
05-14-2008, 02:23 AM
Hi there,
Could you please help me on how to delete row based on some of contidions.
I need to delete row if macth of the criteria, for example: in this case I need to delete row
that containing a value starting to 9500 up to 9507 Or 9530 up to 9531 Or 9550 up to 9552
The data in entire column A as follows:
9550-51119551-51129552-51139553-51149554-51159600-11119549-12215200-59485200-59499530-11129531-11119500-4444
I use the following code, but I can't figure out how to meet those criteria
Sub Test()
Dim RngToDel As Range, XRowsCount As Range
Dim r As Long
Sheets(1).Activate
Set RngToDel = ActiveSheet.Range([A1], [A1].End(xlDown))
On Error Resume Next
Application.Calculation = xlCalculationManual
With RngToDel
For r = .Rows.Count To 1 Step -1
If .Cells(r, 1) = "9500" Or .Cells(r, 1) = "9530" Then
.Cells(r, 1).EntireRow.Delete
End If
Next r
End With
Application.Calculation = xlCalculationAutomatic
End Sub
Appreciate your suggestion on this case.
Many thanks, Harto
Could you please help me on how to delete row based on some of contidions.
I need to delete row if macth of the criteria, for example: in this case I need to delete row
that containing a value starting to 9500 up to 9507 Or 9530 up to 9531 Or 9550 up to 9552
The data in entire column A as follows:
9550-51119551-51129552-51139553-51149554-51159600-11119549-12215200-59485200-59499530-11129531-11119500-4444
I use the following code, but I can't figure out how to meet those criteria
Sub Test()
Dim RngToDel As Range, XRowsCount As Range
Dim r As Long
Sheets(1).Activate
Set RngToDel = ActiveSheet.Range([A1], [A1].End(xlDown))
On Error Resume Next
Application.Calculation = xlCalculationManual
With RngToDel
For r = .Rows.Count To 1 Step -1
If .Cells(r, 1) = "9500" Or .Cells(r, 1) = "9530" Then
.Cells(r, 1).EntireRow.Delete
End If
Next r
End With
Application.Calculation = xlCalculationAutomatic
End Sub
Appreciate your suggestion on this case.
Many thanks, Harto