View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Bruce S[_2_] Bruce S[_2_] is offline
external usenet poster
 
Posts: 4
Default Copy Row to Sheet If Column Value is between time frame

Unfortunately, I'm still getting that same error. Anyway, thanks for your
assistance.

"Bernard Liengme" wrote:

Second offering

Sub moveit2()
Set wks2 = Worksheets("Sheet2")
starthour = InputBox("Give starting hour")
starthour = starthour / 24
endhour = InputBox("Give ending hour")
endhour = endhour / 24
lastcell = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row + 1
j = 1
With Worksheets("Sheet1")
For k = 1 To lastcell
If Cells(k, 1) = starthour And mycell <= endhour Then
Cells(k, 1).EntireRow.Copy Destination:=wks2.Cells(j, 1)
j = j + 1
End If
Next
End With
End Sub

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"Bruce S" <Bruce wrote in message
...
I'm looking for a formula or macro that will allow me to copy rows to an
existing sheet based upon a time range in one column.

For example

Sheet 1 would have two columns (A,B)
ColumnA has times listed in military time (1:00, 13:00, 17:00)
ColumnB has text associated with the time

If Column A is within a specific time range, copy the row(s) to Sheet2