Change range with more then Area to values using VBA in Microsoft Excel

In this article you will learn about how to change range with more than area to values using VBA in Microsoft Excel.

Let’s take an example and understand how to write the VBA code to change the range with more than area to values.

How to change range with more than area to values?

Example 1:-

We have data in Excel A1:C1, in this data we want to paste in the different ranges. Let’s see how?

image 1

 

Follow below given steps:-

  • Press Alt+F11 key to open the Visual Basic Application

image 2

 

  • In VBAProject Double click on Sheet 1
  • Enter the below given VBA Code

 

Sub Values_4()

Dim smallrng As Range

For Each smallrng In Range("A1:D10,E12:H17").Areas

smallrng.Value = Range("A1:D1").Value

Next

End Sub


 
image 1
 

  • To run the code press F5 key
  • Values will be updated in defined small range

image 4

 

Example 2:-

Let’s say we have data in the defined small range and we want to over write that data with the particular range data.

image 5

 

To solve this problem follow below given steps:-

  • Press the key Alt+F11 and double click on sheet 2
  • Enter the below code:-

 

Sub Values_4()

Dim smallrng As Range

For Each smallrng In Range("A1:D10,E12:H17").Areas

smallrng.Value = Range("A1:D1").Value

Next

End Sub


 

  • Run the code by pressing F5
  • Values will get updated

image 6

 

image 48

 

If you liked our blogs, share it with your friends on Facebook. And also you can follow us on Twitter and Facebook.

We would love to hear from you, do let us know how we can improve, complement or innovate our work and make it better for you. Write us at info@exceltip.com

Leave a Reply

Your email address will not be published. Required fields are marked *

Terms and Conditions of use

The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.

Visit Us On TwitterVisit Us On FacebookVisit Us On Youtube