View Full Version : HELP WITH CONCATENATE DATA
krishhi
01-25-2010, 12:17 AM
Hello,
I need help on this following situation.
i need to concatenate the "B" column data on the basis of "A" column.
Just checkout the excel for clear details, i have placed the data in "C" column what i want exactly.
Any macro code available for this situation.
Thanks for your help
Krrish
Bob Phillips
01-25-2010, 01:27 AM
Public Sub ProcessData()
Dim i As Long
Dim LastRow As Long
Dim StartRow As Long
Dim tmp As String
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Columns("C").Insert
For i = 1 To LastRow
If tmp = "" And .Cells(i, "B").Value = "" Then
StartRow = i + 1
Else
tmp = tmp & " " & .Cells(i, "B").Value
End If
If Len(.Cells(i + 1, "A").Value) > 0 Or i = LastRow Then
.Cells(StartRow, "C").Value = Trim(tmp)
tmp = ""
StartRow = i + 1
End If
Next i
End With
End Sub
krishhi
01-25-2010, 01:46 AM
Public Sub ProcessData()
Dim i As Long
Dim LastRow As Long
Dim StartRow As Long
Dim tmp As String
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Columns("C").Insert
For i = 1 To LastRow
If tmp = "" And .Cells(i, "B").Value = "" Then
StartRow = i + 1
Else
tmp = tmp & " " & .Cells(i, "B").Value
End If
If Len(.Cells(i + 1, "A").Value) > 0 Or i = LastRow Then
.Cells(StartRow, "C").Value = Trim(tmp)
tmp = ""
StartRow = i + 1
End If
Next i
End With
End Sub
Millions of thanks for your help.
Can you explain how can i think about to structure coding?
Bob Phillips
01-25-2010, 02:09 AM
Sorry, I don't understand your question.
krishhi
01-25-2010, 02:22 AM
Sorry, I don't understand your question.
K, Leave it.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.