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

workbook.saveasduplicate cell excelexcel macro programming tutorialexcel formula replaceremove doubles in excelsql interview questions for experienced pdfsql manipulation commandsvba powerpoint tutorialexcel vba switch statementranges in vbavba excel redim preserveremove blank rowinsurance dashboard exampleexcel vba lookup functionhow to merge to columns in excelcolor index excelexcel replace in formulasas macro programming for beginnersmerge two columns in excel 2010useful vb scripts for windows 7workbook vbaextract url from hyperlink excelexcel formula colorrename file in vbavba macros tutorialsvba show userformwhat is the len function in excelexcel macro to merge cellsexample of dmlvba application calculationvb6 write text fileexcel vba multiple ifswitch statement vbaadvanced pivot table tutorialgantt charts in excel 2007how to open xml file in excel 2007simple vbaname manager excel 2010unlock excel without passwordexcel tutorial torrenthow to set up a hyperlink in excelvba excel collectionvba do until loopexcel count duplicates in columnvba color chartexcel formulas pdf with example 2007 in hindivba code to unprotect sheetform excel vbahow to create a userform in vbamsgbox access vbaexcel programmer salaryhow to apply autofit in excel 2013application.enableeventsexcel vba sql query exampleunhide first columnsum if in excelhypertext link codeunprotectexcel templates for tracking projectsgantt chart excel download freevba formsvba examples excelxls macro programminghow to insert macro in excel 2007unmerge cellvba excel database examplesinterview questions and answers fresherssumif vbahow to hide and unhide columns in excel 2007vlookup excel worksheetpivot chart tutorialsql data mining tutorialexcel vba redim preservepowerpoint project status dashboard templatevlookup trimiserr excelexcel duplicate worksheetif statements on excelexcel spreadsheet password protectcluster chart excel