×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Excel 2016 Join entries in column A into one row in column b

Excel 2016 Join entries in column A into one row in column b

Excel 2016 Join entries in column A into one row in column b

(OP)
Hi

I am trying to make one long row of information into one cell from many entry's in column A

so I could have 2oo rows in column A

A1 : 100001
A2: 200011
A3: 300000
etc....

I want to be able to make these entrys in Column A into one long entry in B1 with a comma between them.

B1 : 100001, 200011,300000 etc....

How can I do this in one command

Thanks

RE: Excel 2016 Join entries in column A into one row in column b

Would the VBA solution be acceptable?


---- Andy

There is a great need for a sarcasm font.

RE: Excel 2016 Join entries in column A into one row in column b

(OP)
Yes VBA would be ok thanks

RE: Excel 2016 Join entries in column A into one row in column b


CODE

Option Explicit

Sub Cpreston()
Dim intR As Integer
Dim strT As String

intR = 1

Do While Range("A" & intR).Value <> ""
    If intR > 1 Then
        strT = strT & ", "
    End If
    strT = strT & Range("A" & intR).Value
    intR = intR + 1
Loop

Range("B1").Value = strT

End Sub 


---- Andy

There is a great need for a sarcasm font.

RE: Excel 2016 Join entries in column A into one row in column b

I do something a little more generic with a user defined function to concatenate a range of cells

CODE --> vba

Function RangeConcatenate(rngIn As Range, _
        Optional strDelimiter As String = ", ")
    ' Usage
    '  A1 = Red
    '  A2 = White
    '  A3 = Blue
    ' =RangeConcatenate(A1:A3) = Red, White, Blue
    ' =RangeConcatenate(A1:A3," - ") = Red - White - Blue
    
    Dim rngTemp As Range              'each cell
    Dim strTemp As String
    Application.Volatile              'autoupdates
    For Each rngTemp In rngIn         'loop through each cell
        If Len(rngTemp.Text) > 0 Then 'ignore blank cells
            strTemp = strTemp & rngTemp & strDelimiter
        End If
    Next
    If Len(strDelimiter) > 0 Then     'remove the final delimiter
        strTemp = Left(strTemp, Len(strTemp) - Len(strDelimiter))
    End If
    RangeConcatenate = strTemp
End Function 

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016

RE: Excel 2016 Join entries in column A into one row in column b

(OP)
Thanks will give them a go and feed back

RE: Excel 2016 Join entries in column A into one row in column b

I've tried to do it as simple and easy as I could, it could be a base to do what Duane did smile

What I would add:

CODE

Function RangeConcatenate(rngIn As Range, _
        Optional strDelimiter As String = ", ") As String
... 

And you don't really need this check, it is OK to subtract 0 lol :

CODE

If Len(strDelimiter) > 0 Then     
    strTemp = Left(strTemp, Len(strTemp) - Len(strDelimiter))
End If 


---- Andy

There is a great need for a sarcasm font.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close