قالب وردپرس درنا توس
Home / Tips and Tricks / How to make a macro in Excel

How to make a macro in Excel

  Microsoft Office Excel Laptop Meeting

If you understand the basics of Excel, such as formulas and charts, fairly well, you can try automation. These functions are called macros and save time by automating repetitive tasks. Here are a few tips for creating a macro in Excel. This is one of the most advanced tasks we've done yet, so don't worry if you're struggling the first time.

Macros are an advanced Excel function and therefore they fall under the Developer ] tab . If you've never used the Developer tab before, we'll start with tips to set it up.

Enable the Developer tab

1. Right-click anywhere on the tabbed ribbon at the top of your screen and select Customize the ribbon .

  create macro in Excel 1

You can also go through the menu with File> Options> Customize Ribbon but it all depends on your personal preference.

2. Select the Main Tabs option from the menu. It will probably be selected by default, but check this again. Now add a check in the box next to the Developer option.

  Create Macro in Excel 2

The spreadsheet used above to enable the Developer tab is not the sheet we will use to our macro, but the steps remain the same.

Create a macro in Excel

Add a command button

The first thing we need to do when creating our Macro is to add a button . The command button activates the macro as soon as it is composed.

1. Go to the newly added Developer tab and find the section Insert .

  macro excel 1

2. Open the menu and locate Command Button under the section ActiveX Controls .

  macro excel 2

3. Drag your command button to your spreadsheet wherever you want to place it.

  macro excel 3

Assign a macro

Now that you have a command button, it's time to get the button working.

1. Go to the Controls section of the Developer tab. Select Design Mode .

2. Right click on your button and select View Code . This will open the Visual Basic Editor.

  macro excel 4

3. Move your cursor to the Visual Basic editor and select the line between Private Sub CommandButton1_Click () and End Sub.

  macro excel 5

4. Enter this code line: Range ("A1"). Value = "Hello World"

This code adds the phrase Hello World to cell A1 when you click the button.

  macro excel 6

5. Now close the Visual Basic Editor and disable the Design mode option.

6. Test your macro by clicking the command button.

  macro excel 7

This is far from an advanced macro, but it gives you an idea of ​​how the process works. If you want to know how to create an advanced macro in Excel, you need a little more training.

How do I learn more?

As mentioned above, this tutorial is the simplest introduction to using VBA in Excel. If you want to start writing advanced macros or pivot tables, you may want to take a look at some in-depth instructions. You can get this at a great price with a new learning kit currently offered by Tech Deals.

It's called the Complete Excel Pro Tips Certification Bundle and it contains six modules to get you started. You can study more content about data visualization and analysis or explore other features such as pivot tables. The skills you can gain not only look great on your resume, but are also really useful in real life.

  excel pro tips cert

The six modules in the Complete Excel Pro Tips Certification Bundle have a combined retail value of $ 294, but you can already get started for just $ 19. is a great opportunity to brush up on your skills and save some money. You can join the 1,500 people who have already signed up below.