Thread: Delete Rows
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
John Keturi John Keturi is offline
external usenet poster
 
Posts: 19
Default Delete Rows

This looks in column 6 (date column), and supposedly removes those rows
which do not meet the user input date. Ie; users input is 1/1/2003, so this
deletes all rows prior to 1/1/2003. However, I get a run time error on the
line "a.EntireRow.Delete" What does this mean? Thanks

Sub DeleteDates()
Dim TempString As String
TempString = InputBox("Enter beginning Date", "Beginning of Date
Range")
If Not TempString = "" Then
msg = "Removing Data prior to - " & TempString & " , Are you Sure
this is the Correct Date?"
DialogStyle = vbYesNo + vbExclamation + vbDefaultButton1
Title = "Is this the Correct Date?"
Response = MsgBox(msg, DialogStyle, Title)
End If
If Response = vbYes Then
GoTo DeleteData
Else
GoTo Aborted
End If
DeleteData:
For a = 2 To 1000
If Cells(6, a).Value < TempString Then a.EntireRow.Delete
Next
Aborted:
End Sub