Consulting

Results 1 to 3 of 3

Thread: Solved: Combine data from row to one cell

  1. #1
    VBAX Mentor
    Joined
    Feb 2012
    Posts
    406
    Location

    Question Solved: Combine data from row to one cell

    This will combine all data in row 1 into A1. I need to do this for another rows also (that mean loop), how can I do it ?

    [VBA]
    Sub Comb()
    For x = 2 To 256
    If Cells(1, x).Value = "" Then
    Else
    Cells(1, 1).Value = Cells(1, 1).Value & ", " & Cells(1, x).Value
    End If
    Next x
    End Sub

    [/VBA]

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Use a for loop like[VBA]Sub Comb()
    Dim i as long
    for i = 1 to Range("B" & Rows.count).end(xlup).row step 1
    For x = 2 To 256
    If Cells(i, x).Value = "" Then
    Else
    Cells(i, 1).Value = Cells(i, 1).Value & ", " & Cells(i, x).Value
    End If
    Next x
    Next i
    End Sub
    [/VBA]
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    VBAX Mentor
    Joined
    Feb 2012
    Posts
    406
    Location
    Thank you very much for your big help .

Posting Permissions

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