Simple User Form to hold only text

  • Thread starter Thread starter Darin Kramer
  • Start date Start date
D

Darin Kramer

Hi There,

Im trying to find some VB that creates a simple user form with say 10
lines of text underneath each other (Text line 1, text line 2, etc) and
a close button.

Anyone know how.... ?

(PS - User will run a macro that brings up the form - but as the form is
so simple, perhaps there is a less cubersome way to create "pop up" type
info in Excel (not comments or the like!)

Regards

Darin
 
Sub ShowMessage()
s = "Line 1" & vbNewLine
s = s & "Line 2" & vbNewLine
s = s & "Line 3" & vbNewline
s = s & "Line 4" & vbNewline
s = s & "Line 5" & vbnewlIne
s = s & "Line 6" & vbNewline
s = s & "Line 7" & vbNewline
s = s & "Line 8" & vbNewline
s = s & "Line 9" & vbNewline
s = s & "Line 10"
msgbox s
End Sub

Msgbox will only show 255 lines of text, but perhaps that is sufficient.
 
Awesome Tom!!! Thanks!
Is there any way to change the name of the box to my own defined name
instead of "Microsoft Excel"

Kind Regards

Darin
 
Msgbox has several arguments. You might look at the help for a fuller
understanding of its capabilities. Put the code in a module, highight Msgbox
and hit F1. I have added code to change the title.

Sub ShowMessage()
s = "Line 1" & vbNewLine
s = s & "Line 2" & vbNewLine
s = s & "Line 3" & vbNewLine
s = s & "Line 4" & vbNewLine
s = s & "Line 5" & vbNewLine
s = s & "Line 6" & vbNewLine
s = s & "Line 7" & vbNewLine
s = s & "Line 8" & vbNewLine
s = s & "Line 9" & vbNewLine
s = s & "Line 10"
MsgBox Prompt:=s, Buttons:=vbOKOnly, Title:="Darin's advice"
End Sub
 
Darin,

You can change the title of the MsgBox by including the "Title" parameter.
E.g.,

MsgBox "Message Text", vbOKOnly, Title:="MsgBox Title"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 
Just another similar variation:

Sub Demo()
Dim m As Variant
m = Array( _
"Line 1", _
"Line 2", _
"Line 3", _
"Line 4", _
"Line 5")

MsgBox Join(m, vbNewLine), vbOKOnly, "My Title"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top