Tutorial Details
Downloadable Files: Excel File
Introduction to Programming Macros in Excel
First Steps
Getting and Inputting Data
Adding Logic to Macros
UDF- User Defined Functions
Speeding Up Macros

Put Data into a Worksheet using a Macro in Excel

Add to Favorites

How to input data into cells in a worksheet from a macro.

Once you have data in your macro and you do something with it, you need to be able to put it back into Excel so you can see it or store it.

This tutorial assumes that you have read and are familiar with the last tutorial: Get Data from the Worksheet into a Macro in Excel


Putting Data from a Macro into the Worksheet

Putting Data from One Cell into Another Cell Using a Macro


Putting Data from a Macro into the Worksheet

Putting data into a cell is as simple as setting the value of that cell equal to the data.

(If you don't already know how to reference cells in a macro, click that link to learn about it.)

Let's put "This is my data." into cell A1.

  1. Create some data in the macro.
    Here, I set the variable mydata equal to some text.
  2. Enter the location of the cell where the data will go:
  3. Type .Value after it
  4. Set it equal to the variable that has the data that we want to go into that cell.
    You can see this was done using a simple equal's sign and the name of the variable.
  5. Go back to Excel, run the macro, and that's it!

As you can see, it is quite simple to put data into a cell; you only need to know the location of the cell and then set its value equal to something.

Putting Data from One Cell into Another Cell Using a Macro

If you don't need to do anything with the data in the macro, you can simply transfer it from one cell to another cell quickly and easily like this:

Range("B3").Value = Range("A1").Value


This macro gets the data from cell A1 and puts it into cell B3.

After you run the macro, Excel will look like this:


This follows the same format as above except that we get the data directly from another cell.


This is very simple but very important. When building more complex macros, you will always need to use simple features like the one explained in this tutorial.

Make sure to download the sample workbook attached to this tutorial so you can play around with the code and get used to using it.

Question? Ask it in our Excel Forum

Downloadable Files: Excel File