Change the selection with one or more areas to Values using VBA in Microsoft Excel

In this chapter, we are going to learn how to change the selection with one or more areas to values using VBA in Microsoft Excel.

 

Let’s take an example and understand, how we write the VBA code to change the selection with one or more area(s) to values.

How to change the selection with one or more area(s)?

We have data in Excel and we want to update that data in the same sheet but on selection.

image 1

 

Follow below given steps:-

  • Press Alt+F11 to open the Visual Basic Application

image 2

 

  • In VBAProject Double click on Sheet 1
  • Enter the below given VBA Code
Sub Values_10()

Dim smallrng As Range

For Each smallrng In Selection.Areas

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

Next

End Sub

 

image 3

 

  • Select the range E1:E13
  • To run the code press F5
  • Define range will get copy

image 4

 

Conclusion:- In this way, we can update the value on the selection.

These are the VBA coding to update the value from one cell to another cell, one row to another row, one column to another column, one table to another table etc.

 

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.