ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Why won't this work? Syntacs? (https://www.excelbanter.com/excel-programming/392610-why-wont-work-syntacs.html)

[email protected]

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


Leith Ross[_2_]

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


Mike H

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



[email protected]

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



All times are GMT +1. The time now is 03:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com