Change a Column or Columns 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.

How to change the value from column to column?

We have data in Excel in which Column A and column B contains some values, now we want to replace values in Column A values with the values in column B.

image 1

 

Follow these 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_8()

Columns("A").Value = Columns("B").Value

End Sub

 
image 3

 

  • To run the code press F5 key
  • The value of column B will get update in Column A

image 4

 

How to change the value from columns to columns?

We have data in Excel in which Column A, B and C contains some values in a group and Column E, F and G contain values in 2nd group, now we want to change the value of 1st group with the 2nd group.

image 7

 

To change the value follow below given steps and code:

  • Press the key Alt+F11 and double click on sheet 2
  • Enter the below code:
Sub Values_9()

Columns("A:C").Value = Columns("E:G").Value

End Sub

 
image 3

 

  • Run the code by pressing the 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.