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

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.

Follow below given steps:-

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

  • 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

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

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.

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

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

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.

Add a Comment

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