View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chris Van Nuys Chris Van Nuys is offline
external usenet poster
 
Posts: 4
Default Find if between dates

Hi -- Try this, it should do the trick. Nothing fancy in here.

This code will copy all data in between rows B through DD the "lowDate" and
"highDate" that you specify. It assumes your dates are in Row A.

Let me know if you have any questions or need any help.

You need to change the "lowDate" and "highDate" below to match whatever
dates you want it to look between.

I hope this helps, and I hope I've been helpful. Please let me know.

Sub copy_data()
Dim lowDate As String
Dim highDate As String
Dim row As Integer
Dim skiprow As Integer

LastRow = Cells.Find("*", SearchOrder:=xlByRows,
SearchDirection:=xlPrevious).row

lowDate = "1/9/2007"
highDate = "6/1/2007"
row = 0
skiprow = 0

Range("A1:A" & LastRow).Select

For Each Cell In Selection

If Cell.Value < lowDate Then
skiprow = Cell.row + 1
End If

If Cell.Value lowDate And Cell.Value < highDate Then
row = Cell.row
End If

Next

Range("B" & skiprow & ":DD" & row).Select
Selection.Copy
Sheets.Add
ActiveSheet.Paste
Range("A1").Select

End Sub


--
Best of Luck!,

Chris Van Nuys

Become more effective and efficient: Drive your business career by
mastering Excel!


" wrote:

hey everyone

I have date/time in colunm A and data through DD and I would like some
code that would find all the rows that are between two dates/times and
compy them into a different sheet.

Any help would be awesome

Thanks