Automatic Conditional Row Deletion?
Mike,
Sorry for the discrimination, but rules are rules!
I appreciate all your help, but the solution did not work. It deletes only
the top value of column A and keeps every other column the exact same. I
would like the entire row deleted if they were born more than 40 years ago I
have Excel 2003 and the spreadsheet is set up as follows with headers:
Column A - Name
Column B - Address
Column C - Line 2 address
Column D - College
Column E - City
Column F - State code
Column G - Zip Code
Column H - Birthday in xx/xx/xxxx format
Column I - Birthday #2 (If two people)
"Mike H" wrote:
Hi,
It's with some personal pain that I'm to be deleted because I'm over 40 (in
fact twice that) thatI offer you this solution to consider. Right click the
appropriate sheet tab, view code and paste this in on the right. Every time
you select the sheet those poor souls older than 40 are deleted.
Private Sub Worksheet_Activate()
Dim MyRange, MyRange1 As Range
lastrow = Cells(Rows.Count, "H").End(xlUp).Row
Set MyRange = Range("H1:H" & lastrow)
For Each c In MyRange
If IsDate(c.Value) And Int((Date - c.Value) / 365.25) 40 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.Select
End If
Selection.Delete
Range("A1").select
End Sub
Mike
"Go Terps" wrote:
I have a spreadsheet with birthdates listed in column H. Is it possible to
have certain rows automatically deleted when they hit 40 years old (or older)?
|