Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default copying a range of cells from one worksheet to another

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))
  #2   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default copying a range of cells from one worksheet to another

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

"Jim Thomlinson" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default copying a range of cells from one worksheet to another

Initialise jnd to 1

--

HTH

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


"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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default copying a range of cells from one worksheet to another

Whoops, I left that out of the code I cut and paste.
It's been done.
David

"Bob Phillips" wrote:

Initialise jnd to 1

--

HTH

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


"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






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default copying a range of cells from one worksheet to another

Thanks a lot Don. That did the trick.
David

"Don Guillett" wrote:

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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying A Range of Cells to Another Worksheet Rodman Excel Discussion (Misc queries) 4 May 6th 08 09:53 PM
universal copying over worksheet range pat in chard Excel Discussion (Misc queries) 1 April 23rd 08 12:51 PM
Copying cell with input range to different worksheet Doug T[_2_] Excel Worksheet Functions 4 October 4th 07 04:11 PM
Copying a worksheet witrh protected cells to a new worksheet John Excel Worksheet Functions 2 February 1st 06 02:19 PM
How do I skip blank cells when copying over a range of cells? tawells Excel Discussion (Misc queries) 2 June 7th 05 09:36 PM


All times are GMT +1. The time now is 05:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"