Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Inserting Worksheet Values with a Macro.

Inserting Worksheet Values with a Macro

Written by Allen Wyatt (last updated December 16, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


1

Inserting values into a cell is done quite often in macros. In order to insert information into a cell, you use the Value property. For instance, you could use the following to insert a number (23) into cell A1:

Cells(1, 1).Value = 23

For entering information in a cell, the Value property is applicable to any object that resolves to a range. Thus, you could use the following to place a text value ("Address") into the cell at C4:

Range("C4").Value = "Address"

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12613) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel here: Inserting Worksheet Values with a Macro.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Deleting the Open Document File

Want to delete the document you are currently viewing? Word doesn't provide a way to do it, but you can use the macro in ...

Discover More

Printing Post Office Permits on Envelopes

When preparing to snail-mail information, you may want to print your envelopes with permit information in the upper-right ...

Discover More

Turning Off a Dictionary for a Style

There may be some paragraphs in a document that you don't want Word to spell- or grammar-check. You can 'turn off' the ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Getting Rid of the "Enable Macros" Notice

Do you get tired of the dialog box that says "do you want to enable macros" that is displayed when you open a workbook. ...

Discover More

Pausing Macros for User Input

Does your macro need to get some input from a user? Here are the ways that Excel provides for that input to be solicited.

Discover More

Disabled Macros

Do your macros seem to be disabled on your new machine? It could be because of the security settings in Excel. Here's ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 - 5?

2023-12-16 11:09:22

J. Woolley

Value is the default property of a Range object, so the Tip's examples can be coded like this:
Cells(1, 1) = 23
Range("C4") = "Address"


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.