Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
copying a range of cells from one worksheet to another
glad it helped
-- Don Guillett SalesAid Software "David Gerstman" wrote in message ... 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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copying A Range of Cells to Another Worksheet | Excel Discussion (Misc queries) | |||
universal copying over worksheet range | Excel Discussion (Misc queries) | |||
Copying cell with input range to different worksheet | Excel Worksheet Functions | |||
Copying a worksheet witrh protected cells to a new worksheet | Excel Worksheet Functions | |||
How do I skip blank cells when copying over a range of cells? | Excel Discussion (Misc queries) |