copying a range of cells from one worksheet to another

G

Guest

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))
 
G

Guest

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
 
G

Guest

Worksheets(2) is a worksheet "Sheet2" and it is not hidden.
It ranges from A1:D32000
I hope that helps.
David
 
B

Bob Phillips

Initialise jnd to 1

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
D

Don Guillett

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
 
G

Guest

Thanks a lot Don. That did the trick.
David

Don Guillett said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top