View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Another Delete question

Hi,

If I've understood correctly you want to read down column A which is a list
of names and if a name doesn't have a date in column D then delete the row.
If that's correct then right click your sheet tab, biew code and paste this
in and run it

Sub Stantial()
Dim MyRange, MyRange1 As Range
Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:A" & lastrow)
For Each c In MyRange
If Not IsDate(c.Offset(, 3).Value) Then
If MyRange1 Is Nothing Then
Set MyRange1 = c.EntireRow
Else
Set MyRange1 = Union(MyRange1, c.EntireRow)
End If
End If
Next
If Not MyRange1 Is Nothing Then
MyRange1.Delete
End If
End Sub

Mike

"jeremiah" wrote:

I need to group records by the value in column A (employees, who can have
multiple records) and then delete all of any employees who have no records
with a date in column D.

Have given this some thought and have tried filters, loops, offsets and just
can't quite figure out the best way to do it. The groups of records will be
variable each week.