View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tim Zych Tim Zych is offline
external usenet poster
 
Posts: 389
Default Macro deleting row if duplicates found

Sub DeleteBeta()
Dim rng As Range, cell As Range, rngToDelete As Range
Set rng = Intersect(Range("A:A"), ActiveSheet.UsedRange)
For Each cell In rng.Cells
If UCase(cell.Value) Like "*BETA*" Then
If rngToDelete Is Nothing Then
Set rngToDelete = cell
Else
Set rngToDelete = Union(rngToDelete, cell)
End If
End If
Next
If Not rngToDelete Is Nothing Then
rngToDelete.EntireRow.Delete
End If
End Sub


--
Tim Zych
www.higherdata.com
Compare data in workbooks and find differences with Workbook Compare
A free, powerful, flexible Excel utility

wrote in message
...
Is there a macro whereby if I have a list, all in one column, but
different rows:

Column A:

Row 1: Alpha Beta Gamma
Row 2: Alpha Alpha Alpha
Row 3: Beta Gamma Gamma
Row 4: Gamma Gamma Alpha


If I wanted to delete all rows in MS Excel that have the word "Beta"
in it, I should be left with:


Alpha Alpha Alpha
Gamma Gamma Alpha


Thanks.