Assuming you have a userform with two text boxes named
tbxStartDate and tbxEndDate, put the following code behind a
command button. Change the ranges marked with << to the
appropriate locations in your workbook.
Private Sub CommandButton1_Click()
Dim DestRng As Range
Dim SearchRng As Range
Dim StartDate As Date
Dim EndDate As Date
Dim Rng As Range
StartDate = CDate(Me.tbxStartDate.Text)
EndDate = CDate(Me.tbxEndDate.Text)
Set DestRng = Worksheets("Sheet2").Range("A1") '<< CHANGE
Set SearchRng = Worksheets("Sheet1").UsedRange.Columns(1) '<<
CHANGE
For Each Rng In SearchRng.Cells
If Rng.Value = StartDate And Rng.Value <= EndDate Then
Rng.EntireRow.Copy Destination:=DestRng
Set DestRng = DestRng(2, 1)
End If
Next Rng
End Sub
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"excelnewbie166"
wrote in message
...
I have a worksheet where one of the columns is a date column. I
have a
userform for the user to enter their start date and end date
for a
query. I need code that will take the start date and end date
and
compare it to what is in this column. If the date in the column
falls
between the two dates entered, I need all of the information in
the row
to be copied to another worksheet. The dates in the column are
not
sorted.
Any suggestions on where to start? I'm a newbie at this so
please be
gentle.
.
------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from
http://www.ExcelForum.com/