Hello World VBA- Writing Your First Macro

Home/Excel VBA/Hello World VBA- Writing Your First Macro

We have seen how to record a macro in the previous topic, we will see how to write simple Hello World VBA macro. Follow the below steps to do this to show the “Hello World!” message box to the user.



50+ Project Management Templates Pack
Excel PowerPoint Word

Advanced Project Plan & Portfolio Template
Excel Template

Business Presentations Templates Pack
PowerPoint Slides

20+ Excel Project Management Pack
Excel Templates

20+ PowerPoint Project Management Pack
PowerPoint Templates

10+ MS Word Project Management Pack
Word Templates

Hello World VBA- Writing Your First Macro – Step 1: Open the VBA Editor (press Alt+F11)

Hello World VBA- Writing Your First Macro

Hello World VBA- Writing Your First Macro – Step 2: Select ‘Module’ from the Insert Menu

Hello World VBA- Writing Your First Macro

Hello World VBA- Writing Your First Macro – Step 3: Start a new procedure called ‘sbHellow’

To do this write the following line in the module.

Sub sbHello()

And then press Enter. You should see the code as follows:

Sub sbHello()
End Sub
Hello World VBA- Writing Your First Macro – Step 4: This is called a sub procedure where you will write the code as per your requirement.

Our requirement is to show a message as “Hello World!” to do this write following line in the procedure.

MsgBox "Hello World!"

Now your procedure should look like this:
Hello World VBA- Writing Your First Macro

Sub sbHello()
MsgBox "Hello World!"
End Sub
Hello World VBA- Writing Your First Macro – Step 5: You are Done! Yes, now run your macro by pressing ‘F5’

You should see Hello World! message box as shown below:
Hello World VBA- Writing Your First Macro

By |February 23rd, 2013|Excel VBA|0 Comments

About the Author:

PNRao is a passionate business analyst and having close to 10 years of experience in Data Mining, Data Analysis and Application Development. This blog is his passion to learn new skills and share his knowledge to make you expertise in Data Analysis (Excel, VBA, SQL, SAS, Statistical Methods, Market Research Methodologies and Data Analysis Techniques).

Leave A Comment

Related pages

project management powerpoint presentation templateexcel interview questions and answers pdfvba change file namesimple vbaget file name vbamacro ms excelinterview worksheetshow to unprotect excel workbook without passwordvba macro codingexcel interactive graphexcel macro open excel fileactivecellcreate a macro excelchart wizard in excel 2007unlock vba codeproject checklist excelshortcut key for cut in excelexcel cylinder chartexcel delete double entriesmerge text files in excelvba coding for dummiessecure excel spreadsheetddl dml dcl tcl commandsexcel unprotect sheet without passwordwriting macros for excelexcel if cell containstotal no of rows and columns in excelvlookup practice spreadsheetdashboard microsoft excelexcel developer modevba excel redim preservewhat is the match function in excelexcel 2007 formulas with examplesaccess vba queryexcel formula templateswhat does it mean to merge cellsexcel vba sql query access databaseexcel master sheetunhide lines in excelcombobox controlnested if and statements in excel 2010sas macros tutorialalphabetical order in excelhow to unhide column a in excel 2010excel 2010 if statementvba counta functioninsert rows in excel shortcutvba worksheet rangeexcel vba beginnerwhere is developer tab in excel 2010sql query tutorial for beginnershow to do drop down in excel 2007project tracking excel templatevba on error msgboxhow to use name manager in excel 2010sumifs function in excel 2013excel formula insert rowexcel delete named rangehow to consolidate excel sheetsvba programming tutorialexcel 2007 vbavba do until loop examplemacro recording excelproject plan template microsoft wordhow to insert a cell in excelexcel vba clear rangehlook upvlookup excel 2003excel forgot password to unprotect sheetdashboard excel tutorialexcel activeworkbook.saveasvb coding examplesdownloadable gantt charthow to sort excel sheets alphabeticallysql technical interview questions and answers pdf