+ Reply to Thread
Results 1 to 11 of 11

Multiple rows of data that needs merging

  1. #1
    Registered User
    Join Date
    01-03-2013
    Location
    Wales
    MS-Off Ver
    Excel 2003
    Posts
    6

    Multiple rows of data that needs merging

    I think I'm going to need some VBA or a Macro for this query.

    I have a file that exports data to a CSV, depending upon the data, either two rows could be returned for one record (this tends to be the norm) but we could also have data returned that has upto 5 or more rows returned.

    I'll try to demonstrate what I need.
    See attached image as my attempt to create a spreadsheet at bottom of thread failed miserably
    03-01-2013 16-35-39.jpg

    Is somebody able to write me a script so I can work adapt it, there are more columns than this, but hopefully this explains my dilemma.

    This is what I tried to recreate i the thread but the spaces were removed
    ID Name Address Staff No Department Course ID Course Name Pass Mark
    1 Mr A 12 High Street 12345 Accounts 1234 Excel C
    1 Mr A 12 High Street 12345 Accounts 1299 Access B
    2 Mr B 22 Low Close 34567 IT 1234 Excel A
    3 Mr C 96 Middle Road 86745 Accounts 1234 Excel E
    3 Mr C 96 Middle Road 86745 Accounts 1299 Access B
    3 Mr C 96 Middle Road 86745 Accounts 1494 Powerpoint A

    This is what I have to work with and sometimes the data could be 1000+ rows.

    ID Name Address Staff No Department Course ID Course Name Pass Mark
    1 Mr A 12 High Street 12345 Accounts
    1234 Excel C
    1299 Access B
    2 Mr B 22 Low Close 34567 IT
    1234 Excel A
    3 Mr C 96 Middle Road 86745 Accounts
    1234 Excel E
    1299 Access B
    1494 Powerpoint A

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Multiple rows of data that needs merging

    Why upload a jpg when you can upload a sample excel file directly?

    To Attach a File:

    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    01-03-2013
    Location
    Wales
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Multiple rows of data that needs merging

    MyDilemma.xls

    Thank you for that, I have attached a file to help with any replies.

    regards

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Multiple rows of data that needs merging

    Give this a try

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  5. #5
    Registered User
    Join Date
    01-03-2013
    Location
    Wales
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Multiple rows of data that needs merging

    Mike, code is awesome, made some adjustments to take in additional columns, I found one tweak that will probably be easy for you if you knocked this up quickly.

    On the example I gave, all the data was present, some of my fields my have blank data. The code then shifts data up to the incorrect cell.

    If you take out Accounts from Mr A row, you'll see what I mean.

    For full data its smashing and if it cannot be achieved I'm so happy anyway, I'll find and replace blank cells with something and remove them again after (maybe a macro! haha)

    thanks again, and if you can tweak it that would be mint!

  6. #6
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Multiple rows of data that needs merging

    Im not sure what your needing? Can you show me in an example wb?

  7. #7
    Registered User
    Join Date
    01-03-2013
    Location
    Wales
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Multiple rows of data that needs merging

    MyDilemma (2).xls

    Sure, see attached, you'll notice that Mr A has not department associated with him, if you run your code against the attached you'll see what happens.

    My longer spreadsheet has gaps in data as employees are not always the best at filling in forms.

    thanks

  8. #8
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Multiple rows of data that needs merging

    Ok try this then

    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Multiple rows of data that needs merging

    different option, press Run button or run code test
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    01-03-2013
    Location
    Wales
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Multiple rows of data that needs merging

    Thanks Mike, on my larger spreadsheet it does not delete the blank rows, everything else works upto that point but the delete rows are not deleting.

    I just read something about that cells might not truly be blank if data is cut and pasted, could that be it?

  11. #11
    Registered User
    Join Date
    01-03-2013
    Location
    Wales
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Multiple rows of data that needs merging

    Sorted, thanks for all your help Mike, this is going to save me lots of time. After testing out lots of scripts that didn't work, this one did the trick http://pastebin.com/i1HwekA1

    Probably a bit longwinded, but nevertheless, it compliments yours magnificently and i really appreciate you taking the time to help out.

    regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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