S
s_ali_hassan
'ive got a userform into which the user enters a particular date.
'The code then looks at each cell to see if the date in the cell is
'greater than the date entered by the user. If it is, then the row is
deleted
'if not then look at the next cell down.
'stop when nothing is in the cell.
'the problem i have is that, say i enter the date 12/05/2006, then run
the program,
'the dates after 12/05/2006 get deleted (which is correct), but it also
deletes
'12/05/2006 rows aswell (which is not right).
'i cant work out whats wrong, or any other way of doing it. Any help
please? much appreciated.
code:
Private Sub CommandButton2_Click()
Dim date2 As Date
date2 = TextBox2.Text
Range("F9").Select
Do Until ActiveCell.Value = ""
If ActiveCell > date2 Then ActiveCell.EntireRow.Delete
If ActiveCell < date2 Then ActiveCell.Offset(1, 0).Activate
Loop
End Sub
'The code then looks at each cell to see if the date in the cell is
'greater than the date entered by the user. If it is, then the row is
deleted
'if not then look at the next cell down.
'stop when nothing is in the cell.
'the problem i have is that, say i enter the date 12/05/2006, then run
the program,
'the dates after 12/05/2006 get deleted (which is correct), but it also
deletes
'12/05/2006 rows aswell (which is not right).
'i cant work out whats wrong, or any other way of doing it. Any help
please? much appreciated.
code:
Private Sub CommandButton2_Click()
Dim date2 As Date
date2 = TextBox2.Text
Range("F9").Select
Do Until ActiveCell.Value = ""
If ActiveCell > date2 Then ActiveCell.EntireRow.Delete
If ActiveCell < date2 Then ActiveCell.Offset(1, 0).Activate
Loop
End Sub