View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett[_4_] Don Guillett[_4_] is offline
external usenet poster
 
Posts: 2,337
Default copying a range of cells from one worksheet to another

this seems to work

Sub getvalues()
With Sheet2
ii = 2
For i = 2 To .Range("a2").End(xlDown).Row
If .Cells(i, 1) = #6:05:01 PM# Then
.Range(.Cells(i, 1), .Cells(i, .Cells(i, 1).End(xlToRight).Column)). _
Copy Sheets(3).Cells(ii, 1)
ii = ii + 1
End If
Next i
End With
End Sub

--
Don Guillett
SalesAid Software

"David Gerstman" wrote in message
...
I've been trying to copy a range of cells based on the time column to

another
worksheet. The problem I have is with the
Worksheets(2).Cells(ind,1).select
line. I keep on getting a Runtime 1004 error (Application defined or

object
defined error). What is wrong with this code?
Dim date_range As Range
Set date_range = Sheets(1).Range("a2", Range("a2").End(xlDown))
.
.
For Each c In date_range
If c.Value = #6:07:01 PM# Then
Worksheets(2).Cells(ind, 1).Select
Range(select_range, select_range.End(xlToRight)).Select
Selection.Copy Destination:=Sheets(3).Cells(jind, 1)
jind = jind + 1
End If
If c.Value = #6:12:01 PM# Then Exit For
ind = ind + 1
Next c

Thanks,
David