[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2012-03-25
3
Medium Priority
?
999 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This article describes a serious pitfall that can happen when deleting shapes using VBA.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

649 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