PDA

View Full Version : Solved: Combine data from row to one cell



parscon
09-14-2012, 11:43 AM
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 ?


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

Simon Lloyd
09-14-2012, 12:27 PM
Use a for loop likeSub 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

parscon
09-14-2012, 01:02 PM
Thank you very much for your big help .