Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to use Range property properly?

I’d like to copy like this.

what I was thinking

But, this is what I got

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Cell "D2" has problem

My code is quite simple

Range("C1:C2, D1:D2").Value = Range("A1:A2").Value

I just want to copy several cells as a whole into several different places at once using Range propery like this.

Does it has something relationship with Order of Operation ? I mean between "Union Operator"(a Comma) and "Range Operator"(a Colon) within a Range property ?

>Solution :

Range("C1:C2, D1:D2") is a multi-area range.

You need to loop over the .Areas of a multi-area range here:

Dim rng As Range
For Each rng in Range("C1:C2, D1:D2").Areas
   rng.Value = Range("A1:A2").Value
Next
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading