+ Reply to Thread
Results 1 to 8 of 8

Combine multiple rows into a single row with concatenation

  1. #1
    Registered User
    Join Date
    06-20-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Combine multiple rows into a single row with concatenation

    Hi,

    Would love a macro to convert multiple rows to a single row with some of these rows in the result needing to be concatenated... Found a very similar solved thread, but couldn't modify it to produce my desired result. (the link to this thread is: http://www.excelforum.com/excel-new-...02#post2833302).

    I have attached the xlsx with test data. Sheet 1 has the original data, sheet 2 has the result that I want to achieve with a macro...(I have included instructions on how I achieve the result, but it requires way too many manual steps that I'm hoping you can provide a solution to)

    StudentTimetable.xlsxStudentTimetable.xlsx

    Thanks in advance.

    Regards

    Michael
    Last edited by MichaelWood; 06-25-2012 at 01:32 AM. Reason: SOLVED

  2. #2
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Combine multiple rows into a single row with concatenation

    MichaelWood,

    For each student, for each day of the week Monday thru Friday, will there always be 7 rows of data?
    HR
    Period 1
    Period 2
    Period 3
    Period 4
    Period 5
    Period 6


    I have started on the macro coding, but, will not be able to finish it very soon, due to other obligations.

    In the Quick Reply box, just put the word BUMP. Then, click on the Post Reply button, and someone else will assist you.
    Last edited by stanleydgromjr; 06-23-2012 at 11:18 AM.
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Combine multiple rows into a single row with concatenation

    Hi Michael,

    I've been wanting a problem like this to show the differences between Excel Pivot Tables and Access Pivot Tables. In Excel the answer is normally a number, so your problem, to show text in the values area is hard to do. In Access the Pivot Tables show Text. I'm hoping you have Microsoft Access as well as Excel. Then using Access I've imported your first sheet of the attached above. Doing a Pivot Table Query in Access, I used the student code for the report filter and simple drag and drop the other fields to rows and columns.

    I believe the problem is to print out each students schedule with subject, teacher, room and period, etc. If you filter by a single student, their schedule is all displayed. Change the Pivot Table filter to the next student and the data changes. You should be using Access instead of Excel to do this problem.

    I hope this helps.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Combine multiple rows into a single row with concatenation

    Try
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Combine multiple rows into a single row with concatenation

    MichaelWood,


    I have been trying to learn what jindon can do. jindon is the Master.


    Here is a very slight change/addition to his original code (in BOLD) that will add the Room's to worksheet "Result for 3 students".


    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

    1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
    2. Open your workbook
    3. Press the keys ALT + F11 to open the Visual Basic Editor
    4. Press the keys ALT + I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
    7. Press the keys ALT + Q to exit the Editor, and return to Excel
    8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


    Please Login or Register  to view this content.

    Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm


    Then run the updated test macro.

  6. #6
    Registered User
    Join Date
    06-20-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Combine multiple rows into a single row with concatenation

    Thank you sooo much MarvinP, jindon and stanleydgromjr for your efforts, it is greatly appreciated.

    stanleydgromjr your code works perfectly for this data set, thank you.
    Last edited by MichaelWood; 06-25-2012 at 01:32 AM.

  7. #7
    Registered User
    Join Date
    06-20-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Combine multiple rows into a single row with concatenation

    Thanks stanleydgromjr you are brilliant.
    Last edited by MichaelWood; 06-25-2012 at 01:33 AM.

  8. #8
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Combine multiple rows into a single row with concatenation

    MichaelWood,

    Thanks stanleydgromjr.
    You are very welcome. Glad I could help.


    you are brilliant
    No, the brilliant is jindon.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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