Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Add Newline(s) inside a Cell Without Splitting Content into Different Cells

Hi All,

I'm writing output to an Excel file. I have to write all of the
differences into a single cell. Now I've got an output that looks like
this (in a single cell):

The number of text objects differ on page 1: 12; 10 | The number of
text objects differ on page 1: 17; 15 | The number of text objects
differ on page 1: 17; 15 | The number of text objects differ on page 1:
16; 14 | The number of text objects differ on page 1: 17; 15 | The
number of text objects differ on page 1: 18; 16 |

As you can see, it's humanly readable. I want to make it look like
following:

The number of text objects differ on page 1: 12, 10
The number of text objects differ on page 1: 17, 15
The number of text objects differ on page 1: 17, 15
The number of text objects differ on page 1: 16, 14
The number of text objects differ on page 1: 17, 15
The number of text objects differ on page 1: 18, 16

I don't know how to make it look like this. Because, if I add a a
newline ("\r\n") after each difference, this will be split into 6
separate lines - They won't be in the same cell anymore. Any advice?

Thanks!
-Emily

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default Add Newline(s) inside a Cell Without Splitting Content into Different Cells


This is 'a' macro. It dumps the output in Sheet2, Cells A1, A2, A3, A4, etc.


Public Sub splitter()
Dim wb As Workbook, ws As Worksheet
Dim f, b, i As Integer
Dim sInput, sResult As String
Set wb = ThisWorkbook
Set ws = wb.Sheets("Sheet2")
ws.Activate
f = 1: b = 1
sResult = vbNullString
sInput = "The number of text objects differ on page 1: 12; 10 | The
number of text objects differ on page 1: 17; 15 | The number of text objects
differ on page 1: 17; 15 | The number of text objects differ on page 1: 16;
14 | The number of text objects differ on page 1: 17; 15 | The number of
text objects differ on page 1: 18; 16 |"
ws.Cells(f, b).Select
For i = 1 To Len(sInput) Step 1
If Asc(Mid(sInput, i, 1)) < 124 Then
sResult = sResult & Mid(sInput, i, 1)
Else
sResult = LTrim(Left(sResult, Len(sResult) - 1))
ws.Cells(f, b).Value = sResult
sResult = vbNullString
f = f + 1
End If
Next i
End Sub


It's up to you to implement this, because from here I cannot see what your
workbook looks like.






"Emily" schreef in bericht
oups.com...
Hi All,

I'm writing output to an Excel file. I have to write all of the
differences into a single cell. Now I've got an output that looks like
this (in a single cell):

The number of text objects differ on page 1: 12; 10 | The number of
text objects differ on page 1: 17; 15 | The number of text objects
differ on page 1: 17; 15 | The number of text objects differ on page 1:
16; 14 | The number of text objects differ on page 1: 17; 15 | The
number of text objects differ on page 1: 18; 16 |

As you can see, it's humanly readable. I want to make it look like
following:

The number of text objects differ on page 1: 12, 10
The number of text objects differ on page 1: 17, 15
The number of text objects differ on page 1: 17, 15
The number of text objects differ on page 1: 16, 14
The number of text objects differ on page 1: 17, 15
The number of text objects differ on page 1: 18, 16

I don't know how to make it look like this. Because, if I add a a
newline ("\r\n") after each difference, this will be split into 6
separate lines - They won't be in the same cell anymore. Any advice?

Thanks!
-Emily



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
splitting content of a field eintpc5146 Excel Discussion (Misc queries) 3 April 30th 10 02:00 AM
splitting cell content from 1st column into 4 columns Daphtg Excel Worksheet Functions 1 April 28th 10 10:30 PM
Splitting out Content in 1 cell (which is currently separated by"ALT-ENTER") into multiple cells Sunil Ahuja Excel Discussion (Misc queries) 1 March 24th 09 04:27 PM
Add a Newline in a Cell Emily[_3_] Excel Programming 0 September 5th 06 09:42 PM
Splitting Cell content into separate Rows JokerFrowns Excel Programming 13 May 18th 06 08:11 PM


All times are GMT +1. The time now is 09:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"