View Single Post
  #1   Report Post  
PCOR
 
Posts: n/a
Default deleting 4's(four)

Dim Col As Integer
Dim r As Long
Dim c As Range
Dim N As Long
Dim V As Variant
Dim Rng As Range

Hi
I have been using this macro to delete DUplicate in an Excel sheet.
How can I modify it to delete any line where a given col contains a 4(four)
or any other given number?

Thanks
Ian M

On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Col = ActiveCell.Column

If Selection.Rows.Count 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange.Rows
End If

N = 0
For r = Rng.Rows.Count To 1 Step -1
V = Rng.Cells(r, 1).Value
If Application.WorksheetFunction.CountIf(Rng.Columns( 1), V) 1 Then
Rng.Rows(r).EntireRow.Delete
N = N + 1
End If
Next r

EndMacro:

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic






End Sub


--
Norton Professional 2004 says this email is clean...believe it