Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
551 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
As well as altering the text displayed on a message box, you can also change its title. This page describes how to alter the title of a message box.
You can change the title of a message box easily enough. Whether anyone will notice is a different matter.
You can click here to download the file needed for this part of the lesson.
You can click here to download a workbook which contains the sample code.
Extract and open the workbook linked to in the Files Needed section above.
By default, a message box running in Excel will display Microsoft Excel as its title. You can change the title of a message box using the sensibly-named Title parameter. In the workbook you have downloaded, open the VBE and find the subroutine called ChangingTheTitle in Module1. Edit the code in the subroutine to add a title to the message box:
Title is the third parameter of the MsgBox function.
Running the code shown above results in a message box which resembles the one shown below:
Ominous, if not particularly informative.
If you want to set the title of a message box but not the icon, you can skip the Buttons parameter by typing two commas after the Prompt:
MsgBox "Your Prompt goes here", , "Your Title goes here"
To make it easier to tell what each argument is doing, you can write the name of the parameter before each one. Find the subroutine called NamingArguments in Module1. Add the name of the Title parameter to the existing message box and set its value as shown in the code below:
Write the name of the parameter followed by := and then the value you wish to pass to the parameter.
If you use named arguments, you can write them in any order and you don't need to use multiple commas to skip optional parameters:
MsgBox Title:="My Title", Prompt:="My Prompt"
To practise customising the title of a message box:
Sub CustomisingMessages()
MsgBox _
Prompt:="Learning never exhausts the mind", _
Buttons:=vbInformation, _
Title:="Inspirational Quote of the Day"
End Sub
Calling a quote "inspirational" doesn't necessarily make it true.
Sub CustomisingMessages()
MsgBox _
Prompt:="Learning never exhausts the mind", _
Buttons:=vbInformation, _
Title:="Inspirational Quote of the Day"
MsgBox _
Prompt:="So why do I feel so tired?", _
Buttons:=vbQuestion, _
Title:="I'm not sure I agree..."
End Sub
The second message should resemble this one.
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.