VBA basics
7. To run a macro (F5)

Excel macro basics and applications, introduction to Excel VBA
last updated:08-15-2019

7. To run a macro (F5)

Some of this topic was processed by machine translation. Original

Let's run the last macro, “Practice 1”.

There are two main ways to execute macros,

Execute on VBE screen
Execute on worksheet

It can be executed either way for the convenience of the time.

You may have seen a macro run automatically by clicking a button.
It's very convenient, but I will explain this method after learning progresses.

Run on VBE screen

On the VBE screen,

Sub practice1()
  Range("A1") = "Hello!"
End Sub

Of this macro VBA code,
With the input cursor (vertical bar cursor) somewhere between Sub and End Sub,

VBA macros excel

The shortcut F5 should be easy.

Run on worksheet

Let's run it from the worksheet.

Close the VBE (Visual Basic Editor) screen and display the worksheet.


Excel2007, Excel2010 or later
"Developer"-> "Macros"
"Tools"-> "Macros"-> "Macros"


VBA macros excel

Excel Macro VBA image

A screen like this is displayed.

With “practice1” selected (inverted blue)
Click the “Execute” button on the right.

When you run the macro

"Run on VBE screen" "Run on worksheet"
If both methods are executed correctly,

"Good morning!" Is displayed in the cell in column A, row 1 of the worksheet.

After creating a macro, be sure to test it to see if it works properly.
This time, it ’s only one cell, so you can see it right away.
When we handle many cells in the future,
It is very important to check that the macro is working correctly.
Wrong results macros do nothing more than just useless.

Articles with the same theme "VBA basics"

4. Where is the macro written (VBE startup)
5. VBE Set Options (Option Explicit)
6. Let's write it anyway (Sub, End Sub)
7. To run a macro (F5)
8. What is putting a character in a cell (Range, Value)
9. How to specify cells in Range
10. Specification method other than Range (Cells, Rows, Columns)
11. How to use Range and Cells
12. Variables and data types (Dim)
13. Constants and type declaration characters (Const)
14. Character concatenation and continuation line

  • >
  • >
  • 7. To run a macro (F5)

  • If you find this site useful, please share and bookmark.

    I'm going to pay close attention to the description,
    If you have any mistakes or suggestions,「Contact Us」I hope you will let me know.
    Use the posted VBA code at your own risk.
    We are not liable for any damages such as data corruption.

    If you find this site useful, please share and bookmark.
    To the bottom of the text