Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Why won't this work? Syntacs?

I am trying to do a copy and paste using cell information instead of
just ranges because I want to later do a for loop so it's easier. When
I run this it errors and highlights the Cells part. I tried to not use
the cell command and it works fine by just doing....Range(A2:C2).
Please help.


ActiveSheet.Range(Cells(2, 1), Cells(2, 2), Cells(2, 3)).Copy <------
error
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range("c1:e1")

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Why won't this work? Syntacs?

On Jul 3, 11:12 am, wrote:
I am trying to do a copy and paste using cell information instead of
just ranges because I want to later do a for loop so it's easier. When
I run this it errors and highlights the Cells part. I tried to not use
the cell command and it works fine by just doing....Range(A2:C2).
Please help.

ActiveSheet.Range(Cells(2, 1), Cells(2, 2), Cells(2, 3)).Copy <------
error
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range("c1:e1")


Hello Carlos,

The Range object can accept a maximum of 2 arguments. Either a single
range value like Range("C1:E1") or
2 arguments that are the starting address and ending address of the
range. Your code would be written like this...

Activesheet.Range(Cells(2,1), Cells(2,3)).Copy

Sincerely,
Leith Ross

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Why won't this work? Syntacs?

Try this:-
Sub atomic()

Set r1 = Range(Cells(2, 1), Cells(2, 2))
Set myMultipleRange = Union(r1, Cells(2, 3))
myMultipleRange.Select
Selection.Copy
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range("c1:e1")

End Sub

Mike


"Leith Ross" wrote:

On Jul 3, 11:12 am, wrote:
I am trying to do a copy and paste using cell information instead of
just ranges because I want to later do a for loop so it's easier. When
I run this it errors and highlights the Cells part. I tried to not use
the cell command and it works fine by just doing....Range(A2:C2).
Please help.

ActiveSheet.Range(Cells(2, 1), Cells(2, 2), Cells(2, 3)).Copy <------
error
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range("c1:e1")


Hello Carlos,

The Range object can accept a maximum of 2 arguments. Either a single
range value like Range("C1:E1") or
2 arguments that are the starting address and ending address of the
range. Your code would be written like this...

Activesheet.Range(Cells(2,1), Cells(2,3)).Copy

Sincerely,
Leith Ross


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Why won't this work? Syntacs?

On Jul 3, 2:12 pm, wrote:
I am trying to do a copy and paste using cell information instead of
just ranges because I want to later do a for loop so it's easier. When
I run this it errors and highlights the Cells part. I tried to not use
the cell command and it works fine by just doing....Range(A2:C2).
Please help.

ActiveSheet.Range(Cells(2, 1), Cells(2, 2), Cells(2, 3)).Copy <------
error
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range("c1:e1")


I all ready figured it out but thanks to all

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
Macro to update a column in a work based on another work sheet WickerMan New Users to Excel 1 December 4th 09 12:58 PM
how can i automatically generate work order numbers from work orde rob h Excel Discussion (Misc queries) 1 July 13th 09 07:59 PM
If I have a work sheet protected and try to run a macro to hide rows or columns it won't work. Correct? Marc Excel Programming 2 July 12th 06 04:10 AM
Counting dates in multiple work sheets and work books Savage Excel Discussion (Misc queries) 0 December 19th 05 11:41 PM
Is there away to keep "auto save" from jumping to the first work sheet in the work book? Marc New Users to Excel 2 April 21st 05 01:27 AM


All times are GMT +1. The time now is 05:23 AM.

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"