View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_3_] Jim Thomlinson[_3_] is offline
external usenet poster
 
Posts: 983
Default copying a range of cells from one worksheet to another

There are a couple of possible problems here...

Worksheets(2) could be hidden. You can not select on a hidden sheet.
ind may not be between 1 and 65,535.

Since you have not posted the code where this line exists it is a little
hard to tell.

HTH

"David Gerstman" wrote:

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