PDA

View Full Version : How to concatenate several cells



Michael1974
06-23-2015, 05:37 AM
Hello,

Please have a look of the attached. On the Tab called DataImport, I have to concatenate several cells that have the same serial number for example for 87319TOILETMD, I need to concatenate cells J1,J2 and J3. I know how to do that but the issue is if you look at the column A, we have 2 blanks seperating A1 from A4 and only one cell seperating A4 to A6 it is the same scenario throughout the entire column A . How can I can concatenate efficiently in this condition? Please help! Thanks

Michael1974
06-23-2015, 06:28 AM
The end result that I am looking for is located in the Tab called Sheet13 for information. I would really appreciate if someone can help me with this issue

SamT
06-23-2015, 09:03 AM
=CONCATENATE(A1,A4,A6)

apo
06-23-2015, 03:10 PM
Try this..

Click the Button on the DataImport sheet.. result shown on a new sheet i added (Sheet1).



Private Sub CommandButton1_Click()
Dim x, xx, z, cnt As Long, i As Long, ii As Long
x = [A1].CurrentRegion: xx = [A1].CurrentRegion.Columns(1).SpecialCells(2).Count: cnt = 1
ReDim z(1 To xx, 1 To 10)
For i = LBound(x) To UBound(x)
If x(i, 1) <> "" Then
If i > 1 Then cnt = cnt + 1
For ii = LBound(x, 2) To UBound(x, 2)
z(cnt, ii) = x(i, ii)
Next ii
Else
z(cnt, 10) = z(cnt, 10) & " " & x(i, 10)
End If
Next i
Sheets("Sheet1").[A2].Resize(UBound(z), 10).Value = z
End Sub

Michael1974
06-25-2015, 08:10 AM
It is very useful. Thanks