Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to force a new line in text box - Excel userform

Posted on 2012-03-25
3
Medium Priority
?
1,099 Views
Last Modified: 2012-03-25
Hello,

I have a userform that I would like to display a string of text in. I have built the string using the code below:

Private Sub UserForm_Initialize()
Dim rngComments As Range
Dim strcombuild As String
Set rngComments = Range("Comments")
strcombuild = ""
    With Me
        .CommandButton1.Caption = "Close"
    End With

For Each rw In rngComments.Rows
        i = 1
        If rw.Columns(1).Value = TaskID Then
        
            For Each cl In rw.Cells.Columns
                    If i = 1 Then
                        strcombuild = strcombuild & rw.Cells(1, i).Value
                    Else
                        strcombuild = strcombuild & " - " & rw.Cells(1, i).Value
                    End If
                    i = i + 1
            Next cl
            strcombuild = strcombuild & "." & vbNewLine
        End If
Next rw
Me.Textbox1 = strcombuild
End Sub

Open in new window


When I set Textbox1=strcombuild, it just displays one continuous line of text with like a paragraph marker where the carriage / line return should be.

When I assign Label1=strcombuild it displays fine.

I would like to have the text displayed on multiple lines in Textbox1 - any help would be appreciated.

Thanks,

Craig
0
Comment
Question by:slobber72
  • 2
3 Comments
 
LVL 42

Accepted Solution

by:
dlmille earned 2000 total points
ID: 37763667
Just set the .MultiLine property of your textbox to true, and then your vbnewline will be represented in the textbox.

See attached.

Dave
multilineTextbox-r1.xls
0
 

Author Comment

by:slobber72
ID: 37763811
Thanks Dave. Much appreciated.
0
 
LVL 42

Expert Comment

by:dlmille
ID: 37763817
my pleasure.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question