Msgbox Multi-line

Skip Bisconer

Active Member
Joined
Jun 14, 2002
Messages
263
I have tried every combination of Chr(13)+Chr(10) and vbCrLf to get VBA to accept a second line in my msgbox prompt. It's apparant I don't know what I am doing because it justs goes red. Can anyone help me? Thanks
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
On 2002-10-22 17:00, Skip Bisconer wrote:
I have tried every combination of Chr(13)+Chr(10) and vbCrLf to get VBA to accept a second line in my msgbox prompt. It's apparant I don't know what I am doing because it justs goes red. Can anyone help me? Thanks

I think you're probably wanting the _ continuation character in VBA. One thing to remember is that you can have several MSGBOX lines in one VBA line:

MsgBox "line1" & vbCrLf & "line2" & vbCrLf & "line3" & vbCrLf & "line4"

But if you want to have multiple lines in VBA, then you need the underscore continuation character:

Code:
    MsgBox "line1" & vbCrLf & _
           "line2" & vbCrLf & _
           "line3" & vbCrLf & _
           "line4"

HTH,

Russell
 
Upvote 1
Sub hi()
msg = "This is line one"
msg = msg & vbCrLf & "This is line Two"
MsgBox msg
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,631
Messages
6,173,464
Members
452,516
Latest member
archcalx

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