Wraping text to next line

M

morry

I am having trouble wraping text to the next row.

My code is:

Private Sub Submit_LNotes_Click()

With Worksheets("Notes")
cLastRow = .Cells(Rows.Count, "H").End(xlUp).Row
.Cells(cLastRow + 2, "H").Value = "Top Number: " & TopNum.Text
.Cells(cLastRow + 3, "H").Value = "Part Number: "
LPartNum.Text
.Cells(cLastRow + 4, "H").Value = " " & LNotes_Box.Text
End With
LNotesForm.Hide

End Sub

In my third cell that gets information inserted into it, the text ma
be longer that one row. How do I get this to wrap the text onto th
next row so that it stays visible. When I use the wrap text option
under Format Cells it wraps the text but you can only see it if th
cell is selected. Is their a way to wrap the text onto the next row?

Thank you,
Morr
 
T

Tom Ogilvy

Try:
Cells(cLastRow + 4, "H").EntireRow.Autosize

after you enter the text. How much text are we talking about?

or you can do something like this:

sStr1 = LNotes_Box.Text
iloc = instr(len(sStr1)/2,sStr1," ",vbTextCompare)
Cells(cLastRow + 4, "H").Value = " " & Left(sStr1,iloc-1)
Cells(cLastRow + 5, "H").Value = " " & Right(sStr1,Len(sStr1)-iloc)

as in

Sub BBBB()
Dim sStr1 As String
Dim iloc As Long
Dim cLastRow As Long
cLastRow = 5
sStr1 = "The quick brown fox jumped over the lazy dog's back"
iloc = InStr(Len(sStr1) / 2, sStr1, " ", vbTextCompare)
Cells(cLastRow + 4, "H").Value = " " & Left(sStr1, iloc - 1)
Cells(cLastRow + 5, "H").Value = " " & Right(sStr1, Len(sStr1) - iloc)

End Sub
 
K

Ko Vijn

Maybe this:
Cells(myrow, mycolumn).WrapText = True
will wrap text around and adjust the rowheight

Ko Vijn
 

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

Top