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:

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:

'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

Excel VBA UserForms #2

Excel VBA UserForms #2 Create a UserForm with 2 option buttons:  1 Sort by Employee ID or 2 Sort by Name. Part one, create the UserForm and give it buttons. First, bring up the VBA UserForm editor (F11), and add a new UserForm  using the...

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!