Consulting

Results 1 to 5 of 5

Thread: Concatenate Rows Of Data

  1. #1
    VBAX Regular
    Joined
    Sep 2016
    Posts
    16
    Location

    Concatenate Rows Of Data

    Hi,

    I have thousands of rows of data in one column that I am trying to concatenate but it is proving not possible with the concatenate function as there are too many rows. Do you have a macro that could concatenate the rows (each separated by a comma) and then return the value rather than the formula please?

    I know how to do this in Word by replacing ^p with a comma but I need a macro in Excel if possible.

    Thanks very much.

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    You want to concatenate thousands of Strings into one String? The EntireColumn.

    There is a limit to String size, and you might reach that limit. What then?
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Regular
    Joined
    Sep 2016
    Posts
    16
    Location
    Yes, that's correct. Do you know what the limit is? Actually, I could probably limit the number of rows to around 500 if that helps.

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Function DoConCat(Data As Range) As String
        Dim txt As String
        Dim i
        txt = Data(1)
        For i = 2 To Data.Rows.Count
                txt = txt & "," & Data(i)
        Next i
    DoConCat = txt
    End Function
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    VBAX Regular
    Joined
    Sep 2016
    Posts
    16
    Location
    Excellent, thank you!

Posting Permissions

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