.epyt-gallery-thumb{width:33.333%}

One of the most foundational things to learn about when using Excel VBA is how to change a cell value, so that you deal with with this blog post.

On the most basic level, all you have to do is open up the Visual Basic editor in Excel by going to the developer tab and clicking the visual basic editor button. I prefer to use a keyboard shortcut (Alt + F11) to open up the Visual Basic editor.

To create your first macro, you need to add a new module:

Then, when you’re in the new module, we need to create our first macro. We will call it test123 and hit enter.

Now, let’s add some meaningful code. To make A1 become equal to the value “Hello World!”, we need to use Range() to do it. Try this:

1
2
3
Sub test123()
Range("A1") = "Hello World"
End Sub

When we run the macro (F5), it will make the value change in the actual cell as if someone typed it! Awesome!

This was an example of using a String/Text, by surrounding it with quotes. Here are some other examples of data types you can put into cells:

1
2
3
4
5
6
7
8
9
10
'Text Format
Range("A1") = "Hello World"

 

'Date Format
Range("A2") = #12/25/2018#

'Number Format
Range("A3") = 250

For more info, check out this video to help you further:

You Might Also Like

How To Prompt For A File In Excel VBA

**New To VBA?: In these Excel VBA Posts, you'll need to Open The Visual Basic Editor (VBE), and Make a New Module and then Create A New Macro (Sub procedure) in order to paste the code below and use it. Please click the above Tool Tips in this paragraph in order to...

Password Reset
Please enter your e-mail address. You will receive a new password via e-mail.

Pin It on Pinterest

Share This

Share This

Share this post with your friends!