![]() |
Excel VBA - carriage returns
Hi,
I am writing some vba code to split up some text that has been entered in textboxes, and in every case there appears to be carriage returns at the end of each line. Is there a way I can strip out each line and store it in to a seperate variable (eg line1,line2,line3 and line4 - there are a maximum of 4 lines per textbox)? Many thanks KD |
Excel VBA - carriage returns
Hi KD
Linebreaks are either Ascii 10 or Ascii 13 or combinations of the two. If you use Excel 200 or above on Windows, try Replace: Sub test() Dim S As String S = "Hello" & vbNewLine & _ "world" & Chr(13) & _ "how" & vbCrLf & _ "are" & Chr(10) & "You?" MsgBox S S = Replace(S, Chr(10), " ") S = Replace(S, Chr(13), " ") S = Replace(S, " ", " ") MsgBox S End Sub HTH. Best wishes Harald "KD" skrev i melding ... Hi, I am writing some vba code to split up some text that has been entered in textboxes, and in every case there appears to be carriage returns at the end of each line. Is there a way I can strip out each line and store it in to a seperate variable (eg line1,line2,line3 and line4 - there are a maximum of 4 lines per textbox)? Many thanks KD |
All times are GMT +1. The time now is 07:40 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com