TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Excel

Create a Macro Function in MS Excel

Overview

In this tutorial, we will learn the steps involved to Create a Macro Function in an MS Excel document. Macros are disabled by default due to security reasons. We need to save the Excel Workbook with macros in it with the Macro-enables Save option.

Create a Macro Function

Open Start Menu and click the Excel application icon.

Excel Start Menu Entry

Open an Excel Document. Click the Blank workbook option.

This will open a new blank Excel workbook.

 

Windows Excel Blank Sheet

 

Click on the Developer tab. ->> Macros button in the Developer ribbon menu.

In case, if the Developer tab is not present in the menu. Follow the steps outlined here:

https://www.testingdocs.com/customize-the-ribbon-in-ms-excel/

We can find the Macros button in the Developer ribbon.

 

Macros Excel Document

 

Enter the Macro name. Click on the Create button to create the macro.

Choose the scope of the Macro:

  • All Open Workbooks
  • This Workbook

We will create a macro function to print “Hello World”. The macro name is MyFirstMacro()

Add the following simple macro code:

Function MyFirstMacro()
MyFirstMacro = "Hello World"
End Function

 

Macro Code in Excel

Invoke the Macro

In the Excel sheet, Choose a cell to call the macro function. Start typing the function name.

 

Invoke Macro Function Excel

 

Excel would prompt with the function. Select it.

=MyFirstMacro()

 

Macro Output Excel Sheet

 

That’s it. A successful macro would print the Hello World message in the excel sheet cell.

Related Posts

MS Excel Workbook

Excel /

MS Excel Features

Line chart Excel

Excel /

How to Create Line Charts using Excel

‹ How to Create Line Charts using Excel› MS Excel Features

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version