Sub zapit2(targetRange As Range, what As String)
Dim found As Range, first As Range
Set first = targetRange.Find(what, After:=Range("A" & Rows.Count), LookIn:=xlValues, LookAt:=xlWhole)
If Not first Is Nothing Then
Set found = targetRange.FindNext(first)
Do While (Not found Is Nothing)
If (found.Address = first.Address) Then Exit Do
'found.Clear '''''clears the cell found
'found.EntireRow.Clear
'found.EntireColumn.Clear
found.Resize(, 5).Clear '''''changes the size of the range A:E
Set found = targetRange.FindNext(found)
Loop
End If
End Sub
Sub zapit()
Dim targetRange As Range
' change this to where you want to work on
Set targetRange = ActiveSheet.Range("A:A")
zapit2 targetRange, "Grp1"
zapit2 targetRange, "Grp2"
End Sub
|