Change all the cells in the ActiveSheet to values using VBA in Microsoft Excel

In this chapter you will learn how to change all the cells in the active sheet to values using VBA in Microsoft Excel.

Let’s take an example and understand how we write the VBA code for change the cells value in Active sheet.

How to change all the cells value in the Active sheet?

We have data in Excel, in which we want the replace all the cells value with only a cell value.

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_1()

With ActiveSheet.UsedRange

Range("A1:I7").Value = Range("A2").Value

End With

End Sub

 
image 3

 

  • To run the code press F5 key
  • Cell A2 value will get update in the define range

image 4

 

How the change the value from first table to second table?

We have 2 tables, 1st table’s range is A3:I5, and 2nd table range is A8:I10. We want to replace the value of 1st table with the value of 2 table in the active sheet.

image 5

 

To change the value follow below given steps and code:-

  • Open the Visual Basic Application
  • Enter the below code:-

 

Sub Values_1()

With ActiveSheet.UsedRange

Range("A3:I5").Value = Range("A8:I10").Value

End With

End Sub

 
image 6

 

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

image 7

 

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