Setting a .Range to equal another .Range

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.
 
I

isabelle

hi Ronald,

Sheets("Feuil2").Range("A1:B1") = Sheets("Feuil1").Range("A1:B1").Value
 
J

joeu2004

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
 
L

LUIS ANGEL

    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
 
K

kittronald

Isabelle,

Drat !

Just missing the ".Value" at the end.

Merci beaucoup !



- Ronald K.
 
K

kittronald

I was thinking the same thing and left off ".Value".

Adding ".Value" fixed the problem.

Thanks for the quick response.



- Ronald K.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top