+ Reply to Thread
Results 1 to 21 of 21

Pulling Multiple Rows of Data into a Userform

  1. #1
    Registered User
    Join Date
    04-05-2016
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    40

    Pulling Multiple Rows of Data into a Userform

    Hi Everyone,

    In the attached workbook there is a button for "Create Manifest" and a button for "Edit Manifest". After clicking 'create manifest' you can enter info about an order, and upon clicking submit, it writes it to the 'Manifests' worksheet.

    What I am looking for


    I would like for the functionality to then be to be able to click the 'Edit Manifest' button, and to select the reference IDs which may be located on the 'Manifests' worksheet from the combobox, and upon that combobox change, for the text boxes to populate with the information on that corresponding order so that it may be changed.

    Manifests will not always be three lines, and eventually that 'Manifests' worksheet could become hundreds or thousands of rows long.

    I am at a loss for how to accomplish this.
    Attached Files Attached Files

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Pulling Multiple Rows of Data into a Userform

    When you say the Manifests worksheet will contain thousands of rows of data, am I correct in assuming that would cover multiple Reference IDs?
    If so then is there a maximum number of rows of data that any given Reference ID would cover?

    Reason I ask is I think you may struggle with this approach (combo and text boxes for detail) if there could be many many rows per ID as you'd need a very long form and/or need to make it dynamic, which can be a pain in the posterior, and may even run into an upper limit of userform capability.

    Perhaps a slightly different approach...? A simple userform with a combobox to select the Reference ID and a listbox under that which would detail each relevant row of data. The you can scroll through the list if it's too long to view entirely, double click on an item you wish to change and the specific detail of that item would show in a separate userform for updating/amending before taking you back to the listbox form.

    BSB

  3. #3
    Registered User
    Join Date
    04-05-2016
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    40

    Re: Pulling Multiple Rows of Data into a Userform

    Hi BSB -

    Your assumption is correct, there will be many reference IDs and one reference ID can cover many rows (generally not more than 10 rows, but that isn't a guarantee unfortunately).

    That's a good idea, and not one that I had considered! Certainly would seem more functional. I'll give that a go. Would you have any recommendation on how to handle it if I wanted to delete one of the rows and then write it back to the 'Manifests' worksheet?

    Thank you very much for your the suggestion!

    gxm

  4. #4
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Pulling Multiple Rows of Data into a Userform

    Hi gxm,

    No problem at all. I build many tools like this for my day job so have had to develop different solutions for many different scenarios. Your need here is very similar to something I worked on recently which is why that idea sprang to mind.

    I'm not sure what you mean by "if I wanted to delete on of the rows and then write it back to the 'Manifests' worksheet".

    Do you mean in terms of updating a row of data or deleting it and replacing it with an entirely new one?

    BSB

  5. #5
    Registered User
    Join Date
    04-05-2016
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    40

    Re: Pulling Multiple Rows of Data into a Userform

    BSB - I guess I should actually back up and make sure that I can get this to work first!

    I'm struggling with how I can make the combobox populate the listbox. I suppose that's why I didn't think of it, because I've never done it haha. I generally make combo box selections populate text boxes because it is what I know how to do by essentially telling each textbox to equal one value in an array.

    I'm not really sure where to begin with the listbox. Have you got any suggestion on how to make the work or possibly know of another thread where the topic may be covered?

    Thank you again for the help.

  6. #6
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Pulling Multiple Rows of Data into a Userform

    I'm happy to put a demonstration version together for you. It will take me a little while to do (in the middle of a couple of other things right now too) but I'll post back ASAP. It won't necessarily be pretty but with any luck it'll be functional!

    I'll write the code (hopefully) in a simple way that's easy to follow and will add comments to explain it all.

    I just need to know is the sample data in your attachment actually representative of the sort of thing you'll be recording? i.e. your sample data doesn't show text in fields that would be purely numbers in reality, or vice versa? And are there any static lists for any of the fields? If so, which fields and what are the lists?

    BSB

  7. #7
    Registered User
    Join Date
    04-05-2016
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    40

    Re: Pulling Multiple Rows of Data into a Userform

    That would be more help than I could ask for!

    Yes, the information in the Manifests sheet is representative of reality. And no, presently I do not have any static lists for the fields.

    Much appreciated!

    Best regards,

    gxm

  8. #8
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Pulling Multiple Rows of Data into a Userform

    I'm happy to help. Leave it with me and keep an eye on your forum notifications for when I post back.

    Just one other question, the comboboxes for 'Product' and 'Quality', if you don't have any static lists, what are you populating those with? Do they need to be comboboxes or could they just be (freetext) textboxes?

    BSB

  9. #9
    Registered User
    Join Date
    04-05-2016
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    40

    Re: Pulling Multiple Rows of Data into a Userform

    Hey BSB - The idea initially was to have them populated with static lists, however, I changed my mind on that. So certainly no reason they can't be free text boxes.

  10. #10
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Pulling Multiple Rows of Data into a Userform

    Apologies for the delay, as I mentioned I was in the middle of a couple of other things at the time.

    OK, this is a very rough and ready example.

    I've added a "Control" sheet with two self explanatory buttons.

    Click the first to add new manifest details. A form will open with all the usual detail to be completed. Then click the "Add to manifest" button and the data will be stamped to the Manifests sheet.
    The form will then clear, except for the Reference ID field, ready for adding another manifest item for the same ref number.
    When all added, click the "Finished" button to close the form.

    Click the second to open another form. All the previously recorded Reference IDs will be available in the combobox and when you select one (or type it in) the listbox will populate with all rows pertaining to that reference.
    Double click on the record you wish to amend and it will be recalled to a third form (that looks very similar to the first one). You can then change the details and click the "Update Manifest" button to overwrite that record on the Manifests sheet.
    There are some limitations to this given your current data structure but I've included full details of that in a notes section in the amend form module.

    Comments added to the code so you can, hopefully, follow it without too much trouble, but feel free to ask any questions.

    Let me know what you think!!

    BSB
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    04-05-2016
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    40

    Re: Pulling Multiple Rows of Data into a Userform

    Wow this is incredible! Thank you so much. I'm going to play around with it and read through it, but it looks like it'll do!

    Thank you again for taking the time out of your day!

    Best,

    gxm

  12. #12
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Pulling Multiple Rows of Data into a Userform

    No problem at all. Happy to help.

    Much of it I took from something I'd already built and just amended it to fit this project.

    Happy to answer any follow-up questions you have.

    BSB

  13. #13
    Registered User
    Join Date
    04-05-2016
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    40

    Re: Pulling Multiple Rows of Data into a Userform

    Hey BSB - this is a few weeks on now but I do have a question on this. First off, thank you so much for the help as this has really been working out for me.

    My question is if you would have an idea about how I could control where in the spreadsheet the new Manifest Line gets added. Right now this is looking at a combination of Reference ID and Cases as a unique identifier. What if I knew that I wanted to add a new Manifest line above/under a specific row in tblManifests? Would you have any idea for what I could add/change to make that possible?

    No worries if you've not got the time! You've already done plenty for me.

    Thanks!

  14. #14
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Pulling Multiple Rows of Data into a Userform

    Hi gxm,

    Apologies for the delay. Been away from the forum for a couple of days.

    Inserting at a certain point in the table is certainly possible by changing the below line to include the red part.
    Please Login or Register  to view this content.
    The number in parenthesis will determine the row number below the table header that a new line will be inserted. 1 would be directly below the headers, 10 would be ten rows below etc.

    How do you determine which row to insert at? Are you looking to group Reference IDs or similar?

    If so it would be possible to find the last instance of a Ref ID and insert a row after that. Or may be just as simple to add a new row to the bottom of the table then sort the data to group things.

    Let me know how you decide where to insert and I'll amend the VBA.

    BSB
    Last edited by BadlySpelledBuoy; 01-11-2019 at 04:05 PM.

  15. #15
    Registered User
    Join Date
    04-05-2016
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    40

    Re: Pulling Multiple Rows of Data into a Userform

    Hi BSB! No worries at all - glad to hear back from you.

    Yes, what I am looking to do is to insert a row below a specific combination of Ref ID and Product. I am looking to approach it this way because for each Ref ID there may be multiple different products, and if I add a line, I would like for all of the like products to remain with each other.

    So essentially I'd like for the macro to look for the first or last line where specific combo of Ref ID + Product exists and then add the new row below that.

    Let me know if I need to clarify further - not always the best at explaining requirements hahah!

    Best,

    gxm

  16. #16
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Pulling Multiple Rows of Data into a Userform

    Try this version. It will look for the Reference ID in column A and the Product in column C, searching from the bottom row upward.
    When it finds a match on both it will insert a new row underneath that row and add the details from the form there.

    I hope that's what you meant.

    BSB
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    04-05-2016
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Microsoft Office Professional Plus 2013
    Posts
    40

    Re: Pulling Multiple Rows of Data into a Userform

    A savior as always. That's exactly it. Thanks a million times!

  18. #18
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Pulling Multiple Rows of Data into a Userform

    Happy to help

    BSB

  19. #19
    Registered User
    Join Date
    04-19-2021
    Location
    italy
    MS-Off Ver
    2007
    Posts
    1

    Re: Pulling Multiple Rows of Data into a Userform

    Quote Originally Posted by BadlySpelledBuoy View Post
    Try this version. It will look for the Reference ID in column A and the Product in column C, searching from the bottom row upward.
    When it finds a match on both it will insert a new row underneath that row and add the details from the form there.

    I hope that's what you meant.

    BSB
    Hello everyone, hello Badlyspellebuoy. I found this thread and your vba solution to this specific userform after a long search on the internet.
    I want to tell you your work and userform are very much apreciated.
    I tried to tailor it to my nedds, and it works fine, except for the inserting row under the matching ID and product (found in columns A and C)
    It inserts new row with the matching Id and product at the bottom of the table...and NOT under the existing rows with matching ID.
    I am using the add manifest command button in the control sheet btw.
    Could you please, kindly ndicate what do I have to edit in the vba in order for the userform to add the new row under the last one with matching ID and product?
    Thank you so much in advance for any help you are willing to give.

  20. #20
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Pulling Multiple Rows of Data into a Userform

    I suspect that would be happening because you have blank rows at the bottom of the table, so rather than tag the new line at the end of the data it tags it to the end of the table.
    There is rarely a need to have blank rows at the end of a table as formatting and formulas etc. will get copied down as you add new data.

    Delete the blank rows and it will work just fine.

    If that's not the case, start a new thread with a copy of your file including any amendments to the code.
    Send me a PM when you've done that in case I miss it and I'll take a look.

    BSB

  21. #21
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Pulling Multiple Rows of Data into a Userform

    Quote Originally Posted by claireexcel View Post
    Hello everyone, hello Badlyspellebuoy. I found this thread and your vba solution to this specific userform after a long search on the internet.
    I want to tell you your work and userform are very much apreciated......

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ 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] Deleting Multiple Rows of data from a USERFORM button.
    By sorensjp in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-22-2017, 10:25 PM
  2. UserForm input data to multiple rows
    By howey9 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-10-2015, 05:37 PM
  3. [SOLVED] Save all UserForm data for multiple rows
    By onmyway in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-02-2015, 02:22 PM
  4. pulling multiple date ranges from 1 cell into multiple rows?
    By 13lack13lade in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-01-2013, 11:50 PM
  5. Pulling Data from multiple sheets and inserting rows
    By jMedia in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2012, 03:03 PM
  6. Pulling multiple columns, rows data from other worksheet
    By lamazi in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-11-2012, 11:46 AM
  7. [SOLVED] VBA Userform Pulling data from txt file
    By TalResha in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-18-2012, 08:33 AM

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