Thread: Exclude date
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
DataHog DataHog is offline
external usenet poster
 
Posts: 9
Default Exclude date

Okay the other routine bombed - this really works this time.

I have just learned when using dimension as Date it must be mm/dd/yyyy format.

So I changed my code to:
Dim Reeks1 As Date
Dim Reeks2 As Date
and
If Format(Cells(i, "G"), "mm/dd/yyyy") = Reeks1 And _
Format(Cells(i, "H"), "mm/dd/yyyy") < Reeks2 Then


So you must use format cells - standard date format mm/dd/yyyy on Column G & H

And this code will work.

Sub CommandButton7_Click()
Dim lngLastRow As Long
Dim i As Long
Dim Reeks1 As Date
Dim Reeks2 As Date
Reeks1 = Application.InputBox("Start Date", Default:=Range("G2").Value,
Type:=9)
If Reeks1 = False Then Exit Sub
Reeks2 = Application.InputBox("End Date",
Default:=Range("H1").End(xlDown).Value, Type:=9)
If Reeks2 = False Then Exit Sub
lngLastRow = Sheets("Sheet1").Cells(Rows.Count, "G").End(xlUp).Row

For i = lngLastRow To 2 Step -1
If Format(Cells(i, "G"), "mm/dd/yyyy") = Reeks1 And _
Format(Cells(i, "H"), "mm/dd/yyyy") < Reeks2 Then
Else
Rows(i).EntireRow.Delete Shift:=xlUp
End If
Next i

End Sub


"Basta1980" wrote:

Hi DataHog,

This 2 doesn't change the problem.