View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Macro if greater than letter then delete

I told you that already.

--
Regards,
Tom Ogilvy

"mike b" wrote in message
...
If the code is left as is will it delete the row when it finds one of the
letters to delete? If not what line of the code do I need to change?

Thanks
Mike

"Tom Ogilvy" wrote:

Sub EFGH()
Dim rngC As Range, rngF As Range
Dim rng As Range, rng1 As Range
Dim rw As Range
On Error Resume Next
Set rngC = Range("F:H").SpecialCells(xlConstants)
Set rngF = Range("F:H").SpecialCells(xlFormulas)
If rngC Is Nothing And rngF Is Nothing Then Exit Sub
If Not rngC Is Nothing And Not rngF Is Nothing Then
Set rng = Intersect(rngC, rngF)
ElseIf rngF Is Nothing Then
Set rng = rngC
Else
Set rng = rngF
End If
On Error GoTo 0
Set rng = Intersect(rng.EntireRow, Range("F:H"))
For Each rw In rng.Rows
If Application.CountIf(rw, "D*") 0 Or Application.CountIf(rw, "E*")

0
Then
If rng1 Is Nothing Then
Set rng1 = rw
Else
Set rng1 = Union(rng1, rw)
End If
End If
Next
If Not rng1 Is Nothing Then
rng1.EntireRow.Select
End If
End Sub

If that identifies the rows you want to delete, then change
rng1.EntireRow.Select to rng1.EntireRow.Delete

--
Regards,
Tom Ogilvy





"mike b" wrote in message
...
Hello,

I need a macro that can look at columns F, G and H, if any of those

columns
have a letters D-, D, D+ or E then delete the row.

Thanks for your help
--
Mike B