PDA

View Full Version : [SOLVED] Merge and Combine data



parscon
02-18-2014, 03:02 PM
Hello ,

i have 2 sheet in sheet1 I have 4 column like the below image that you see A To D and column A have duplicate data but other column Have Different data .

I need to merge all column that their column A is same and give me the result like second image on sheet2

Please help me on this subject

http://i61.tinypic.com/28h0whg.png

I need this result in sheet2 , that mean data on column C1 added to first of data on column B1 and add () and dara on column D1 added between ().
http://i62.tinypic.com/2ljjna1.png

p45cal
02-19-2014, 09:03 AM
didn't notice it was solved! Anyway:
Sub blah()
Set StartCll = Sheets("Sheet1").Range("A1")
Do Until IsEmpty(StartCll)
ofst = 0
Do Until StartCll.Value <> StartCll.Offset(ofst).Value
ofst = ofst + 1
Loop
Set EndCll = StartCll.Offset(ofst - 1)
Set block = Range(StartCll, EndCll)
Set Destn = Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Offset(1)
StartCll.Copy Destn
ReDim myStrings(1 To block.Rows.Count)
i = 1
For Each celle In block.Cells
myStrings(i) = Join(Array(celle.Offset(, 2).Value, celle.Offset(, 1).Value, "(" & celle.Offset(, 3).Value & ")"), " ")
i = i + 1
Next celle
Destn.Offset(, 1) = Join(myStrings, ", ")
Set StartCll = EndCll.Offset(1)
Loop
End Sub