Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
splitting content of a field | Excel Discussion (Misc queries) | |||
splitting cell content from 1st column into 4 columns | Excel Worksheet Functions | |||
Splitting out Content in 1 cell (which is currently separated by"ALT-ENTER") into multiple cells | Excel Discussion (Misc queries) | |||
Add a Newline in a Cell | Excel Programming | |||
Splitting Cell content into separate Rows | Excel Programming |