Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
While I know you have already have a solution to your problem, I thought you
(and others reading this thread) might be interested in a totally different approach to doing what you asked. Just change the worksheet and range references for the two Set statements to the source of your data and the destination the "sentences" are to be placed at in this macro... Sub CombineToSentences() Dim X As Long, LastRow As Long Dim AllWords As String, Words() As String, Sentences() As String Dim Source As Range, Destination As Range Set Source = Worksheets("Sheet1").Range("A2") Set Destination = Worksheets("Sheet2").Range("B3") With Source.Parent LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row ReDim Words(0 To LastRow - 1) For X = 0 To LastRow - Source.Row Words(X) = Source.Offset(X).Value Next End With AllWords = Join(Words) Sentences = Split(AllWords, "") For X = 1 To UBound(Sentences) Destination.Offset(X - 1).Value = "" & Sentences(X) Next End Sub By the way, if your "sentences" are to be *real* sentences and they do not need to preserve the greater than () symbol, just use this statement inside the last For..Next loop in place of the statement I have there now... Destination.Offset(X - 1).Value = Sentences(X) -- Rick (MVP - Excel) "LaDdIe" wrote in message ... Happy New Year! Could I have some help to find a solution to my task. In column A I have about 3000 rows of data, The string in the first cell starts with the symbol , which then follow with strings in preceeding cells which do not start with the symbol , then again there may be a another string in a cell which does start with the symbol . I need a macro that looks from top to bottom in col A for a string that starts with , then combine that string with other strings below that do not start with , if the string below starts with then it should stop combining. Simply put the symbol denotes the start of a sentence. Any help will save my little fingers goinig numb |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Combine multiple rows into one. | Excel Discussion (Misc queries) | |||
Formula/ Macro to combine data from multiple rows | Excel Programming | |||
How do I combine multiple rows with like data in Excel? | Excel Discussion (Misc queries) | |||
Combine Data from Multiple Rows | Excel Discussion (Misc queries) | |||
Combine multiple rows to 1 row.... help | Excel Programming |