Message Box Functions in VB

AndrewKent

Well-known Member
Joined
Jul 26, 2006
Messages
889
Hi there everyone,

This is probably a really easy one to answer...

I've been adding in message boxes to my macros to prompt a response from the user however some message boxes will contain a bit of text information before the initial prompt question, how do I get this to show on two separate lines and centred in the message box...

Code:
Dim Ans As Integer
    Ans = MsgBox("You are about to produce the Monthly Illness & Absence Report for Bancassurance Telephony." & vbCrLf & "Do you wish to continue?", vbYesNo)
    Select Case Ans
        Case vbYes '

Thanks in advance,

Andy

PS - if anyone knows of any decent tutorial websites that deal with the basics of VB that would help and stop me from asking daft questions :oops:
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Unfortunately, there is no built-in way to center the text on a msgbox. You can add spaces to move the text over to *appear* centered, though.

As for multiple lines: use a line feed. For example:

Code:
Msgbox "This is line 1." & vbCrLf & "This is line 2."

You could also use either Chr(10) or vbNewLine in place of vbCrLF. All three do the same thing :)
 
Upvote 0
Try it this way:
Code:
MsgBox "You are about to produce the Monthly Illness & Absence Report for Bancassurance Telephony." & Chr(13) & "Do you wish to continue?", vbYesNo
 
Upvote 0
Yeah after twenty minutes of playing around with it I figured out there was nothing I could about this apart from adding in spaces. Thanks for the workaround guys!
 
Upvote 0

Forum statistics

Threads
1,214,984
Messages
6,122,601
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top