Consulting

Results 1 to 5 of 5

Thread: HELP WITH CONCATENATE DATA

  1. #1

    HELP WITH CONCATENATE DATA

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Quote Originally Posted by xld
    [vba]

    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
    [/vba]
    Millions of thanks for your help.
    Can you explain how can i think about to structure coding?

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Sorry, I don't understand your question.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    Quote Originally Posted by xld
    Sorry, I don't understand your question.

    K, Leave it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •