Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Merging cells with same parent.

Hi,

I have three columns.
Column 1 has family-numbers (sorted ascending).
Column 2 has row-numbers (starting with 1 at the first instance of a new
family)
Column 3 has text.

Example:
FAM Row Text
1 1 These lines
1 2 belong to
1 3 eachother.
2 1 Do you want a
2 2 peanutbutter sandwich?
3 1 My daddy
3 2 lives in
3 3 a great big
3 4 block of flats.

As you can see there is no fixed number of texts belonging to any family.

Now I want something that merges for each family it's child-texts together,
separated by a space, and after that, delete the duplicate family rows.

Looking forward to your reply.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Merging cells with same parent.

Try the below macro which works on the active sheet. Row 1 will have headers
and you data is in the 1st 3 columns..

Sub CombineText()
Dim lngRow As Long, lngLastRow As Long, strData As String
lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row

For lngRow = lngLastRow To 2 Step -1
strData = Trim(Range("C" & lngRow)) & " " & Trim(strData)
If Range("B" & lngRow) = 1 Then
Range("C" & lngRow) = strData: strData = ""
Else
Rows(lngRow).Delete
End If
Next
End Sub

--
If this post helps click Yes
---------------
Jacob Skaria


"Pluggie" wrote:

Hi,

I have three columns.
Column 1 has family-numbers (sorted ascending).
Column 2 has row-numbers (starting with 1 at the first instance of a new
family)
Column 3 has text.

Example:
FAM Row Text
1 1 These lines
1 2 belong to
1 3 eachother.
2 1 Do you want a
2 2 peanutbutter sandwich?
3 1 My daddy
3 2 lives in
3 3 a great big
3 4 block of flats.

As you can see there is no fixed number of texts belonging to any family.

Now I want something that merges for each family it's child-texts together,
separated by a space, and after that, delete the duplicate family rows.

Looking forward to your reply.

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
merging cells and eliminating spaces for empty cells Jill Excel Discussion (Misc queries) 2 April 2nd 10 07:43 PM
merging cells justinc Excel Discussion (Misc queries) 1 May 28th 09 08:30 PM
Formula for merging cells/re sizing cells Mathicas Excel Discussion (Misc queries) 1 September 29th 08 08:16 PM
merging cells together but keeping all data from the cells Pete C[_2_] Excel Discussion (Misc queries) 3 May 16th 08 10:14 PM
merging cells Debbie New Users to Excel 0 October 1st 06 04:34 PM


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

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

About Us

"It's about Microsoft Excel"