+ Reply to Thread
Results 1 to 31 of 31

Combining Multiple Rows with same uniquie identifier

  1. #1
    Registered User
    Join Date
    02-26-2017
    Location
    Brunswick, GA
    MS-Off Ver
    2016
    Posts
    18

    Combining Multiple Rows with same uniquie identifier

    Good day to everyone.

    I am very green at using excel. I find myself in a position where I have to modify, edit a csv file and quite honestly - after searching the web for many days I can't say I have found the right solution for my question.
    I know merging cells, concatenating is fairly common - but I am not sure how common my request is.
    I'll explain and post a snippet. I have a CSV file - 4 columns. There is a unique identifier available. I am trying to combine; organize; move all like rows - accordingly to the unique identifier onto one row. (I have to import this into a tool and the way this csv file is, each row will overwrite the previous row. There isn't any appending options here) NOTE: Each unique identifier could be on 6 rows upto perhaps 30 rows. It's basically structured for Additional Features and a Description.
    (product features: some products have six features, some products have 30 features.) Attached here is what I currently have. The second attachment is what I am after. My apologies but the actual attachment paperclip option is not working for me. The column names, I do not think have any relevancy - I used feature and desc as an example. But I have to add, there isn't any consistency with the number of rows. I have products that use upt 30 rows. Any advice, assistance would greatly be appreciated by this noob.

    prod_details.PNG

    How I want Prod Desc CSV.PNG

    I need to mention that COLUMN C looks to be consistent with its naming convention - it is not. The SEQUENCE column (I have yet to find the commonality because I have found SEQ and it's value associated with different.
    There are many products that have a Name OTHER FEATURES in Column C. Unfortunately those instances could have numerous rows. Example attached.

    Other Features Example.PNG
    Last edited by whozitsdad; 02-26-2017 at 11:33 AM.

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Combining Multiple Rows with same uniquie identifier

    Welcome to the forum

    Look below and it tells you another way to post a file. We need 2 sheets
    - the before sheet
    - the "What I want to see" sheet

    As I understand it you want
    - everything for the same item no on the same row

    Q1 Does that mean ItemNO /SeqNo / Feature / descr /SeqNo / Feature / descr /SeqNo / Feature / descr / ....?
    and (perhaps more importantly)...
    Q2 Do you want ALL Seq 10 to be in one column, ALL Seq 11 to be in column etc?
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Registered User
    Join Date
    02-26-2017
    Location
    Brunswick, GA
    MS-Off Ver
    2016
    Posts
    18

    Re: Combining Multiple Rows with same uniquie identifier

    Hi Kev and thank you for the welcome.

    1st: Toss out the SEQ - there isn't any relevancy that I can find for its use.
    So Itemno / Feature / Descr / Feature 2 / Descr 2 / Feature 3 / Descr 3 and so on depending of course on the number of rows per Unique Identifier.

    As mentioned some ITEMNO contain six rows and upto perhaps 30 rows.

    Thanks
    Terry

    PS: if you look on the 3rd attachment: 00037 OTHER FEATURES You'll notice several descriptions listed but missing the OTHER FEATURES text beside it. I'd be happy just to merge that specific group of cells into one if that makes any sense. I'm assuming it's going to require some VBA, way out of my league.
    Last edited by whozitsdad; 02-26-2017 at 03:51 PM.

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Combining Multiple Rows with same uniquie identifier

    VBA is the way I would go

    You did not answer Q2
    Do you want ALL Seq 10 to be in THEIR OWN column, ALL Seq 11 to be in THEIR OWN column etc?

    Please attach a workbook - saves me having to recreate..
    thanks

  5. #5
    Registered User
    Join Date
    02-26-2017
    Location
    Brunswick, GA
    MS-Off Ver
    2016
    Posts
    18

    Re: Combining Multiple Rows with same uniquie identifier

    Hi Kev. I did answer you about the SEQ. Get rid of them, they are of no use at all. Give me a minute and I'll PM you the workbook.
    Thanks
    Terry

  6. #6
    Registered User
    Join Date
    02-26-2017
    Location
    Brunswick, GA
    MS-Off Ver
    2016
    Posts
    18

    Re: Combining Multiple Rows with same uniquie identifier

    I can't post an attachment. Even zipped up the paperclip does not provide an option to attach.

  7. #7
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Combining Multiple Rows with same uniquie identifier

    to add attachment - see bottom of my first post - ignore the paperclip

  8. #8
    Registered User
    Join Date
    02-26-2017
    Location
    Brunswick, GA
    MS-Off Ver
    2016
    Posts
    18

    Re: Combining Multiple Rows with same uniquie identifier

    I followed what you did.
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Combining Multiple Rows with same uniquie identifier

    thanks.
    got it and will look at it in a couple of hours.

  10. #10
    Registered User
    Join Date
    02-26-2017
    Location
    Brunswick, GA
    MS-Off Ver
    2016
    Posts
    18

    Re: Combining Multiple Rows with same uniquie identifier

    Thank you.

  11. #11
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Combining Multiple Rows with same uniquie identifier

    See if this does what you want.
    - Try it first with the cut-down database - Sheet "Additional Details" now only contains 220 lines.
    - Run it in the attached workbook with {CTRL} + t
    - It runs almost instantly.

    Then try it with the complete database by copying the vba below into your original file.
    I fear that it will take a long time to run with so many rows. Will look to make it faster if very slow.

    I'm signing off for the night. I look forward to your feedback


    Put in a general module:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    02-26-2017
    Location
    Brunswick, GA
    MS-Off Ver
    2016
    Posts
    18

    Re: Combining Multiple Rows with same uniquie identifier

    Thank you. I'll give it a shot.

  13. #13
    Registered User
    Join Date
    02-26-2017
    Location
    Brunswick, GA
    MS-Off Ver
    2016
    Posts
    18

    Re: Combining Multiple Rows with same uniquie identifier

    Hi Kev. When I open up that excel file, switch to the cut down sheet and do the CTRL + T Nothing happens.

  14. #14
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Combining Multiple Rows with same uniquie identifier

    Apologies - when I read back what I wrote I can see why you misunderstood
    The result is in Sheet "Additional Details" - is that where you are looking? It may be messed up if you have run the macro several times - it will look rather different to the image below
    It may be easiest to delete the file and download it and try again
    - open it and enable edit and macros etc
    - leave it open on Sheet "Additional Details"
    and run the macro with {CTRL} t (hit and hold control key when you hit the t)

    How the Sheet "Additional Details" should look
    OneRow.jpg
    Last edited by kev_; 02-27-2017 at 03:01 AM.

  15. #15
    Registered User
    Join Date
    02-26-2017
    Location
    Brunswick, GA
    MS-Off Ver
    2016
    Posts
    18

    Re: Combining Multiple Rows with same uniquie identifier

    I am going to try this again now. I'll redownload your attachment.
    Sorry, the wife has been horribly ill.

    Terry

  16. #16
    Registered User
    Join Date
    02-26-2017
    Location
    Brunswick, GA
    MS-Off Ver
    2016
    Posts
    18

    Re: Combining Multiple Rows with same uniquie identifier

    That worked perfect. Now what? lmao

  17. #17
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Combining Multiple Rows with same uniquie identifier

    I hope your wife is feeling much better.
    Next try to run the VBA with the complete data set - I remember being concerned that it would take quite a long time to run.
    So to test, either:
    A) paste all the data into sheet Additional Details in the workbook I posted
    OR:
    B) insert the VBA in a general module in your own workbook which contains all the data in Sheet Additional Details
    And see how long it takes. If it takes too long I'll have a re-think
    Kev

  18. #18
    Registered User
    Join Date
    02-26-2017
    Location
    Brunswick, GA
    MS-Off Ver
    2016
    Posts
    18

    Re: Combining Multiple Rows with same uniquie identifier

    Did I tell you it did work in your sample? I'm not sure how to apply it to my CSV file now.
    Thanks
    Terry

  19. #19
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Combining Multiple Rows with same uniquie identifier

    Close all your other applications and files - running this macro will need all the PC's resources
    Choose a time when you do not need to use your PC for a while.

    Open up the csv file in Excel
    - Immediately re-save it as a "macro-enabled workbook"
    - Open VBA window with {Alt} {F11}
    - Insert a module
    - Paste in the VBA
    - Close VBA window ( X in top right corner)
    - Save the file (do this before running the macro)
    - Run the macro
    - How long does it take to run?
    (30 minutes?)

    SaveAs.jpg

    VBA window.jpg

    VBA window2.jpg

    RunMacro.jpg

  20. #20
    Registered User
    Join Date
    02-26-2017
    Location
    Brunswick, GA
    MS-Off Ver
    2016
    Posts
    18

    Re: Combining Multiple Rows with same uniquie identifier

    Brilliant. IT seemed to have worked.
    I left but looks like 40 minutes to completion. I just have a wee bit of editing but they are all on its own row
    Thank you Ken. I really appreciate this.

  21. #21
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Combining Multiple Rows with same uniquie identifier

    You are welcome.
    Would appreciate it if you mark the thread as solved after you have verified all is ok.
    thanks
    Kev

  22. #22
    Registered User
    Join Date
    02-26-2017
    Location
    Brunswick, GA
    MS-Off Ver
    2016
    Posts
    18

    Re: Combining Multiple Rows with same uniquie identifier

    10 4 I will Kev.

  23. #23
    Registered User
    Join Date
    02-26-2017
    Location
    Brunswick, GA
    MS-Off Ver
    2016
    Posts
    18

    Re: Combining Multiple Rows with same uniquie identifier

    45 minutes to completion I have another question for you though if you would entertain it.

  24. #24
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Combining Multiple Rows with same uniquie identifier

    Always happy to entertain questions - may not be able to answer it though!
    Perhaps best to start a new thread.

  25. #25
    Registered User
    Join Date
    02-26-2017
    Location
    Brunswick, GA
    MS-Off Ver
    2016
    Posts
    18

    Re: Combining Multiple Rows with same uniquie identifier

    Heh. Well I'm impressed as heck anyways. The VBA script worked like a champ. The only thing that is hampering me is, when the data is moved to its appropriate line in the new fields - is there anyway to keep the columns/fields consistent?
    IE: Lets use BULLET TYPE for example. It shows up in several columns. BULLET WEIGHT as another example might show up in several columns.
    So how that hampers me is I have to import this CSV file into a web application. Drag and drop. Header / description.
    If I was able to align all equal/same headers in the same column(s) it would make my importing into another app easier. I can predict the order and choose what I need.
    The way it is now, I dont know which column the BULLET TYPE heading might be in.

    Does that make sense?

    The attachment shows a FIND I did. In the CELL you will see J, H, L N and so forth. I'd love to have all my "criteria" in
    Attached Images Attached Images
    Last edited by whozitsdad; 03-13-2017 at 02:47 PM.

  26. #26
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Combining Multiple Rows with same uniquie identifier

    Yes VBA can give you what you need. But we need to take step back to go forward. As I am away from my PC, I am unable to examine your original data file, but from memory
    - seq 0 to 79 have unique "features"
    - seq 80 and above do not

    So let's use those "features" as our column headers up to seq 79, and from 80 onwards we use "Feature 80", "Feature 81" etc. A separate column is required for each seq - this ensures that everything is collated in the way you want.
    To achieve this, VBA will
    1. add "Feature 80", "Feature 81" etc where column C in your original data file contains blanks
    2. sort the data by item number then by seq - this should make the next step quicker
    3. Use whichever method is quickest to match the item's seq to the correct column (I need to test on your data)
    4. Place the feature "description" in the correct colum for each item

    I will update the thread with the code when I get back to my PC

  27. #27
    Registered User
    Join Date
    02-26-2017
    Location
    Brunswick, GA
    MS-Off Ver
    2016
    Posts
    18

    Re: Combining Multiple Rows with same uniquie identifier

    The seq number has to have some significance. I for one can't quite figure it out yet. I've attached what you probably already know.
    One would assume the Seq(uence) number would be unique .... however it is not. The ItemNo is, but the Seq number seems to relate to varying headers/titles/identifiers.

    Anyways, I appreciate your help
    Attached Images Attached Images

  28. #28
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Combining Multiple Rows with same uniquie identifier

    Thanks - it's time for a quick backpedal then:
    - column headers will be either the text in column C or (where column C is blank) "Feature 80", "Feature 81" etc.

    Can you run a few queries - seq 80+ versus the description in column D to see if you can discern any pattern/logic?
    - can we use seq 80, 81 etc to group common features
    - or were seq nos allocated at random when the items were set up?

    It would be good if we could make the columns collect the same type of descriptions together if there is some discernable logic. But perhaps this will need to be done separately for seq 80+ (perhaps using a helper column etc)

  29. #29
    Registered User
    Join Date
    02-26-2017
    Location
    Brunswick, GA
    MS-Off Ver
    2016
    Posts
    18

    Re: Combining Multiple Rows with same uniquie identifier

    Thanks Kev.
    I'll try when I get home after work.
    Terry

    And correct: only glancing over several, rows - my first thought was YAY, consistency with SEQ, then I was let down lol

  30. #30
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Combining Multiple Rows with same uniquie identifier

    Have a go with this code - this may be pretty close to what you are looking for.
    See attached workbook (which contains the code)
    - sheet "Additional Details" - contains a few of your original records
    - sheet "Results" - show what those few items look like after being processed
    - header text repeated in cells (I am not sure if you want it there or not)
    - sheet "Errors" - blank in attached file but when you run it against complete data set expect a handful of items to be listed (VBA steps over the errors - they are due to invalid data resulting from the import)

    This code runs faster than the previous code and I have added a timer.
    Let me know what you think.


    What you need to do:
    Replace all the previous code with this and give it a go against your data
    (VBA assumes that the values are held in sheet named "Additional Details")

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

  31. #31
    Registered User
    Join Date
    02-26-2017
    Location
    Brunswick, GA
    MS-Off Ver
    2016
    Posts
    18

    Re: Combining Multiple Rows with same uniquie identifier

    4 minutes to complete. About 40 records created errors.

+ 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. Replies: 7
    Last Post: 01-12-2017, 03:42 AM
  2. Replies: 3
    Last Post: 08-20-2014, 02:31 PM
  3. Replies: 4
    Last Post: 03-03-2014, 04:48 AM
  4. Replies: 2
    Last Post: 12-07-2013, 02:34 AM
  5. Replies: 2
    Last Post: 12-04-2013, 09:45 PM
  6. Combine multiple rows into one with a unique identifier
    By fordco in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-19-2013, 07:04 PM
  7. Macros to move multiple rows of data for same unique identifier into one.
    By TPMIS in forum Excel Programming / VBA / Macros
    Replies: 31
    Last Post: 07-05-2013, 03:14 PM

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