View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Mitchell_Collen via OfficeKB.com Mitchell_Collen via OfficeKB.com is offline
external usenet poster
 
Posts: 27
Default VBA code deleting everything not just rows with specified values. Please help.

Wow thanks! It works!
I really envy your gift with programming logic!

:-) -Misty

JE McGimpsey wrote:
One possibility:

Public Sub DeleteSpecificRows()
Dim rCell As Range
Dim rDelete As Range
Dim vTargets As Variant
Dim i As Long

vTargets = Array("outpatient chronic", "dialysis treatments", _
"Medications", "Ferrlecit*", "Zemplar*", "Cathflo*", "Clarity")
For Each rCell In Range("A1:A" & _
Range("A" & Rows.Count).End(xlUp).Row)
With rCell
For i = LBound(vTargets) To UBound(vTargets)
If LCase(.Text) = vTargets(i) Then
If rDelete Is Nothing Then
Set rDelete = .Cells
Else
Set rDelete = Union(rDelete, .Cells)
End If
End If
Next i
End With
Next rCell
If Not rDelete Is Nothing Then rDelete.EntireRow.Delete
End Sub

Hi VBA Professionals.
Please see my code. I am trying to only delete rows in an excel sheet where

[quoted text clipped - 56 lines]
Application.ScreenUpdating = True
End Sub


--
Message posted via http://www.officekb.com