View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Go Terps[_2_] Go Terps[_2_] is offline
external usenet poster
 
Posts: 3
Default Automatic Conditional Row Deletion?

I tried a few different times after I formatted the column to both normal
date and customer date with mm/dd/yyyy and neither worked.

Sorry to bother you, but do you have any other suggestions?

"Mike H" wrote:

I find that difficult to explain because i've tested it again and it works
perfectly with properly formatted dates in Column H which I suspect may be
your problem. I suggest you check the dates are correctly formatted.

Mike

"Go Terps" wrote:

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)?