Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
viewing carriage returns in excel 7 | Excel Discussion (Misc queries) | |||
Remove carriage returns in an Excel document? | Excel Discussion (Misc queries) | |||
Removing carriage returns from excel | Excel Worksheet Functions | |||
Carriage Returns Excel 2003 | Excel Discussion (Misc queries) | |||
Removing Carriage Returns in Excel 2000 | Excel Discussion (Misc queries) |