excel for microsoft 365 excel for microsoft 365 for mac excel 2019 excel 2016 excel 2019 for mac excel 2013 excel 2010 excel 2016 for mac more… less

if you have tasks in microsoft excel that you do repeatedly, you can record a macro to automate those tasks. a macro is an action or a set of actions that you can run as many times as you want. when you create a macro, you are recording your mouse clicks and keystrokes. after you create a macro, you can edit it to make minor changes to the way it works.

Bạn đang xem: Quick start: Create a macro

suppose that every month, you create a report for your accounting manager. you want to format the names of the customers with overdue accounts in red, and also apply bold formatting. you can create and then run a macro that quickly applies these formatting changes to the cells you select.

how?

quick start: create a macro

before you record a macro    

macros and vba tools can be found on the developer tab, which is hidden by default, so the first step is to enable it. for more information, see show the developer tab. quick start: create a macro

quick start: create a macro

record a macro    

  1. in the code group on the developer tab, click record macro.

  2. optionally, enter a name for the macro in the macro name box, enter a shortcut key in the shortcut key box, and a description in the description box, and then click ok to start recording.

    quick start: create a macro

    Xem thêm: Cách đổi số thành chữ trong Excel bằng VnTools

  3. perform the actions you want to automate, such as entering boilerplate text or filling down a column of data.

  4. on the developer tab, click stop recording.

    quick start: create a macro

quick start: create a macro

take a closer look at the macro    

you can learn a little about the visual basic programming language by editing a macro.

to edit a macro, in the code group on the developer tab, click macros, select the name of the macro, and click edit. this starts the visual basic editor.

see how the actions that you recorded appear as code. some of the code will probably be clear to you, and some of it may be a little mysterious.

experiment with the code, close the visual basic editor, and run your macro again. this time, see if anything different happens!

next steps

  • to learn more about creating macros, see create or delete a macro.

  • to learn about how to run a macro, see run a macro.

how?

quick start: create a macro

before you record a macro    

make sure the developer tab is visible on the ribbon. by default, the developer tab is not visible, so do the following:

  1. go to excel > preferences… > ribbon & toolbar.

  2. in the customize the ribbon category, in the main tabs list, select the developer check box, and then click save.

    Xem thêm: Cách nối Sheet trong EXCEL

quick start: create a macro

record a macro    

  1. on the developer tab, click record macro.

  2. optionally, enter a name for the macro in the macro name box, enter a shortcut key in the shortcut key box, and a description in the description box, and then click ok to start recording.

  3. perform the actions you want to automate, such as entering boilerplate text or filling down a column of data.

  4. on the developer tab, in the code group, click stop recording.

quick start: create a macro

take a closer look at the macro    

you can learn a little about the visual basic programming language by editing a macro.

to edit a macro, in the developer tab, click macros, select the name of the macro, and click edit. this starts the visual basic editor.

see how the actions that you recorded appear as code. some of the code will probably be clear to you, and some of it may be a little mysterious.

experiment with the code, close the visual basic editor, and run your macro again. this time, see if anything different happens!

need more help?

you can always ask an expert in the excel tech community or get support in the answers community.