+ Reply to Thread
Results 1 to 11 of 11

Concatenate variable number of lines within a column

  1. #1
    Registered User
    Join Date
    04-18-2013
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    28

    Question Concatenate variable number of lines within a column

    Hi,
    I would like your help with the following issue

    I have many questions in a column (column c) and each question is in several lines, there is not an exact number of lines, some times a question can occupy 2 lines and some others 10 or more lines,
    I want to concatenate the different lines of each question within a single line . I also have a number (100) in colum B, these number are in the exact same line as the beginning of each question, maybe I can use these numbers as delimiters for the concatenate formula. In the excel file there is an example of what I have and what I want
    Thank you very much for your help

    Fernando
    Attached Files Attached Files

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Concatenate variable number of lines within a column

    Hi Fernando,
    Welcome to the forum.

    If you are open to a VBA solution to this, please find the attached workbook and click on the button on the sheet to run the macro to get the desired output.
    Enable the macros while prompted after opening the workbook.
    Attached Files Attached Files
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Registered User
    Join Date
    04-18-2013
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Concatenate variable number of lines within a column

    Hi sktneer,
    very good solution, but I realized that in some cases there is not space between the questions and in some other cases there are spaces between the answers and the macro does not do the right concatenation in those cases. The file that I uploaded is an example, the real columns are different, how can I change the column in the macro?


    the questions are like here

    question1
    a
    b

    c
    d

    question 2
    a
    b
    c
    question 3

    a
    b
    c

    d
    question 4

    a
    b
    c...
    I appreciate your help
    Thanks

    Fernando
    Last edited by ferndiazabarca; 05-03-2015 at 01:41 AM.

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Concatenate variable number of lines within a column

    Something like this?
    Attached Files Attached Files

  5. #5
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Concatenate variable number of lines within a column

    Here is the modified code with your new sample workbook from post#3.

  6. #6
    Registered User
    Join Date
    04-18-2013
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Concatenate variable number of lines within a column

    Sktneer you are a Master, that is exactly what I need. In the example my column source is C, if I need to change the colum source lets say M, where do I need to put it in the Macro

    Thank you very much

    Fernando

  7. #7
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Concatenate variable number of lines within a column

    Here is the code used with some added comments......
    Make the changes to suite your requirement.

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    04-18-2013
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Concatenate variable number of lines within a column

    Sktneer

    Thank you very much
    you really are a genious I was struggling to try to make it work using concatenate but I couldn't
    Thank you very much
    Muchas gracias
    Merci beaocoup

    Fernando

  9. #9
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Concatenate variable number of lines within a column

    You're welcome. Glad I could help.
    De nada. Me alegro de poder ayudar.

    If that takes care of your original question, please mark your thread as Solved by selecting Thread Tools (just above your first post) --> Mark thread as solved.


    tener cuidado

  10. #10
    Registered User
    Join Date
    04-18-2013
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Concatenate variable number of lines within a column

    Muchas gracias
    Te deseo todos los exitos del mundo
    un fuerte abrazo
    Fernando

  11. #11
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Concatenate variable number of lines within a column

    Muchas gracias.
    Era placer trabajar con usted .
    Todo lo mejor

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Variable number of lines in a Linest
    By marcinhafernandez in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-04-2014, 04:16 PM
  2. [SOLVED] Concatenate variable number of lines
    By GlynRD in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 06-17-2013, 07:57 AM
  3. How to concatenate a variable number of rows/cells based on multiple criteria?
    By jonharadon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-16-2012, 09:22 PM
  4. Concatenate address lines of varying number
    By tone640 in forum Excel General
    Replies: 4
    Last Post: 08-08-2011, 08:18 AM
  5. Concatenate (combine) Header Row with Variable Number of Detail Rows
    By cral17 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-29-2009, 09:19 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1