ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Wraping text to next line (https://www.excelbanter.com/excel-programming/292331-wraping-text-next-line.html)

morry[_12_]

Wraping text to next line
 
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

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Wraping text to next line
 
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

--
Regards,
Tom Ogilvy


"morry " wrote in message
...
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 may
be longer that one row. How do I get this to wrap the text onto the
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 the
cell is selected. Is their a way to wrap the text onto the next row?

Thank you,
Morry


---
Message posted from http://www.ExcelForum.com/




Ko Vijn[_3_]

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

Ko Vijn

"morry " schreef in bericht
...
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 may
be longer that one row. How do I get this to wrap the text onto the
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 the
cell is selected. Is their a way to wrap the text onto the next row?

Thank you,
Morry


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 10:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com