Setting a .Range to equal another .Range

  • Thread starter Thread starter kittronald
  • Start date Start date
K

kittronald

On Sheet1,

A1 = One

B1 = Two

What is the proper code to set ...

Sheet2.Range("A1:B1")

to be equal to Sheet1.Range("A1:B1") , so that on Sheet2

A1 = One

B1 = Two



- Ronald K.
 
kittronald said:
On Sheet1,
A1 = One
B1 = Two
What is the proper code to set ...
Sheet2.Range("A1:B1")
to be equal to Sheet1.Range("A1:B1") , so that on Sheet2
A1 = One
B1 = Two

Assuming that Sheet1 and Sheet2 are Worksheets variables that you set as
follows:

Set Sheet1 = Sheets("sheet1")
Set Sheet2 = Sheets("sheet2")

you would think the following would suffice since .Value is the default
member for Range variables:

Sheet2.Range("a1:b1") = Sheet1.Range("a1:b1")

But for reasons I cannot explain, statements of that form require .Value
written explicitly at least on the right-hand side, to wit:

Sheet2.Range("a1:b1") = Sheet1.Range("a1:b1").Value
 
    On Sheet1,

        A1 = One

        B1 = Two

    What is the proper code to set ...

        Sheet2.Range("A1:B1")

    to be equal to Sheet1.Range("A1:B1") , so that on Sheet2

        A1 = One

        B1 = Two

- Ronald K.

simply put in sheet 2

in cell a1 put
=sheet1!a1

in cell b1 put
=sheet1!b1
 
I was thinking the same thing and left off ".Value".

Adding ".Value" fixed the problem.

Thanks for the quick response.



- Ronald K.
 
Back
Top