+ Reply to Thread
Results 1 to 56 of 56

For Loop to Add Items to a Listbox!!!

  1. #1
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Red face For Loop to Add Items to a Listbox!!!

    LISTBOX EXAMPLE.xlsx

    I am trying to create a listbox in an order sheet that populates the listbox with Names from a master sheet by comparing the Store number.

    So Store number in Sheet1 = 999
    The bottom of the order sheet has Food Products or should, I want a listbox there that populates the food product names from the master list by adding whatever items from Sheet 2 that have Store number = 999 in Colum C...

    So, Store number in Sheet1 = 999
    Sheet 2
    Column A Column C
    Lettuce 999
    Tomatoes 999
    Bread 742
    Onions 874

    So the listbox should have Lettuce and Tomatoes in it not the others... obviously this is a small example and there are hundreds of items but can someone please help me on how to do this... I cannot figure it out using VBA...
    Last edited by cory0789; 09-03-2014 at 09:47 PM.

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: For Loop to Add Items to a Listbox!!!

    We'll need a sample workbook. Specifically, where you want the listbox. On the sheet or in a userform?
    David
    (*) Reputation points appreciated.

  3. #3
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    Sample added, the listboxes will be under the products on the order sheet, if you have more questions just ask I will do my best to explain and help out!!!! Thanks for the help

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: For Loop to Add Items to a Listbox!!!

    Use data validation.

    1. Select the range you want data validation in (B11:B16)
    2. In the ribbon go to Data -> Data Validation -> Data Validation
    3. In the box that just popped up under the Allow combobox select "List"
    4. Click the "Source" text box. Select the Master List sheet. Select your product range D6:D16. Click Ok

  5. #5
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    That will not work as the master list can always change and I only want the items that have the identical store number to populate in dripdown list...

  6. #6
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: For Loop to Add Items to a Listbox!!!

    stnkynts was right. A validation list would be best. But what you need is a filtered validation list.

    See if this is what you're looking for.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    I will need this listbox to prepopulate the rest of the information in the prder sheet based on the selection it should bring up prive, location and other stuff from the master list when a product is selected... Will this still work if so how will i reference that?

  8. #8
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: For Loop to Add Items to a Listbox!!!

    Sounds like you are looking for a a worksheet change event on the dropdown boxes. Not all of the information on the preorder sheet is in the master list so I have included to code for the code location. You can follow the theme with the main sheet to get the rest of the data.

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    Hmmm im trying to figure this out ill do some research to why it doesnt work and see if i can fix it.

  10. #10
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: For Loop to Add Items to a Listbox!!!

    It does work. I tested it on Tinbendr's sheet (which he did a really nice job on for you). Make sure you are putting the code in the proper place under sheet 1 in the VBE

  11. #11
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    Yea but i cant get it to work on a bigger sheet there is something different in the code I really appreciate the help!!! Thank yall so much!!! Im away from pc now but ill work with it again later again Thanks a ton

  12. #12
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: For Loop to Add Items to a Listbox!!!

    I've been working on this again. Found an error with lastrow on Sheet1. Removed some duplication. Added comments. It seems much more stable now.
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    Works like a champion!!!! the listbox part that I asked for, if anyone wants to help me make the other information populate based on listbox selection that would be AWESOME!!

  14. #14
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    Where in the code is it making the other data validation lists for the order form, how do I move them up and down or add more to the order form so I can continually add more products...???

  15. #15
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    I have attached the big spreadsheet I am working with trying to get all of this working... I need the order form to have listboxes to select the product in the a column starting at A31, I dont know what else to do to get that... I also need it to populate the corresponding data on the order form from the master list based on the selection in COLUMN A...

    Thanks in advance

    Invoicing Testing.xls

  16. #16
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: For Loop to Add Items to a Listbox!!!

    Wow! I couldn't get it to work either.

    I have an idea for a different approach. But, I'll have to work on it over the weekend.

  17. #17
    Forum Contributor mongoose36's Avatar
    Join Date
    06-10-2013
    Location
    Lincoln
    MS-Off Ver
    Excel 2013
    Posts
    389

    Re: For Loop to Add Items to a Listbox!!!

    Changing your Workbook_Open subroutine to the following worked for me to get unique Sold To values.
    Please Login or Register  to view this content.
    If your questions has been answered to your satisfaction please don't forget to do the following:

    Add Reputation ... and ... Mark Thread as Solved

    Thanks,

    Ma 10:8b Freely you have received; freely give.

  18. #18
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    I have that part working, but I need help when I select a product that it populates the row in the order sheet with the data in the master list row for that selected product...

    Thanks,

  19. #19
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    Ok, I believe I have the concept down of what I can do to get around it if nobody can help me figure it out that way... I can use the combo box on change event to clear the filter on the master list, then when a sold-to is selected the data is filtered down to only that sold to... this will eliminate getting the wrong results... this or if there is a way to use vlookup in vba and reference the product name as well as the sold-to number to get the row results within the order sheet....

  20. #20
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: For Loop to Add Items to a Listbox!!!

    Ok, this is a different approach using cascading comboboxes, instead of validation lists.
    Attached Files Attached Files

  21. #21
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    I have no idea how that works... can you explain how I can add more things for it to post cause I need it to bring everything from the row on the master list to the order sheet for each one except like 2 colunmns... I didnt think it would be this complicated to be honest...

    I can say this I do not need a combo box on each order sheet for the sold-to number... those are constant numbers and will be the same for each location so I wont need to change the sold to ever on any order sheet but they WILL be different on each sheet if that makes sense.. .Anton will be the 10004018 number and Mallet will be like a 837281 number... but they will always be the same...

    That being said could the listbox selection on the product be a macro of some type that uses a vlookup that pulls that product from the master list with the Sold-to number off of the order sheet and brings all of the data from the sheet and inputs it into each cell on the order sheet... Hopefully this can be done all in a macro or behind the scenes kind of how you did it but without it showing what it will be inputing just mabye select the product and hit post and it does it the first row in the order sheet and then pick a different product and it goes to the next row but adds all of the data I need...

    Sorry to keep this going but I really need this to work the right way for me to get the rest of this project completed properly

  22. #22
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: For Loop to Add Items to a Listbox!!!

    I finally realized that the Sheet name was the filter that you were looking for. I assumed that the sold-to-number and the sheet name were a parallel item.

    Using the validation list, we could use vlookup once the product number is chosen. Now that I'm getting the feeling about how the sheet works, using a validation list shouldn't be a problem. And I think it might be possible without using auto-filter.

    I'll try to work on it again tomorrow. I'm about to turn in. It's been a long weekend. (I took the wife car shopping and I'm exhausted. We were successful.)

  23. #23
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    Invoicing Testing Update.xls

    I need the data below to be input into the order sheet... I cannot find where the error is so I have re-attached the new file updated the master list and see if you can help me out, I didnt realize what you did already does what I ask I just need to figure out a way to put it to the side of the sheet instead of a popup as we would prefer not having a popup like that...

    Thank you for all the help!!!!

    Please Login or Register  to view this content.

  24. #24
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    It's been a long weekend. (I took the wife car shopping and I'm exhausted. We were successful.)

    I hear you, hope that new car did not empty your pocket books!!! haha that is excellent though I really appreciate all the help with this!!

  25. #25
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: For Loop to Add Items to a Listbox!!!

    OK, see how this one is working for ya!

    When the workbook opens, it calls the UpdateValList macro that assigns all the values equal to the sheet name from the master list in Rows B30:B50. (This can be adjusted ,of course.) This will create a validation list for each Plant name, filtered to include only those chemical names. Since the macro is in the module, it can be run anytime the master sheet is updated.

    Then I created a formula to pull the corresponding data from each group.

    The hickup has been that there are multiple products across different customers. Looking those up was beyond vlookup. But I finally found a Index/Match formula that seems to work pretty good. I had to add the sheet name to a cell (A2) so that the formula could be dynamic across sheets. If this is a problem, you can always hard code the sheet name in the formula.
    Attached Files Attached Files

  26. #26
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    I need to be able to add things to the Master list and the prices need to correspond even when the Master list is not in order... Is this possible? Also, I dont see where you are adding the stuff to the order sheet but it is doing it can you explain where it is doing this?

  27. #27
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    Invoicing Testing Full Sheet.xls

    Ok, I figured out you just put the index formula in each box but when I try to change it even if I change it to something and change it back it gives me N/A... why is that??? this way will work perfectly if I can get the bugs worked out or atleast I think it will... I have attached the master sheet that I am working with mabye you will be able to see a little better what exactly I am going after...

    I am hoping to be able to add more things to the master list whenever needed in the future and it will automatically update the listbox and everything... even if I have to make a button for it or something that will be fine.


    Thanks,

  28. #28
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    I cannot get the index formula to work at all nor will the update val list update any other sheet than the anton sheet... ???? Can you please help me with this this is excatly what is needed I just cannot figure it out to finish the job!!!

    I just get N/A everywhere when trying to move the formula around or even when putting the formula back the way it was... I also get an error something global failed when I open the file...

    Thanks
    Last edited by cory0789; 09-09-2014 at 12:39 AM.

  29. #29
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: For Loop to Add Items to a Listbox!!!

    The formula is an array formula and you have to enter it using Ctrl-Shift-Enter. There should be Curly Brackets around it after you use that key combination.

    Please Login or Register  to view this content.
    The trailing number is the column returned from the Master sheet minus one. (Since the index range starts in Column B.) I had trouble matching the columns since they don't have the same headers between sheets, so I left the job of copying them across to you. Sorry I didn't mention that.

    Just to reiterate, the sheet name has to be in A2. I use a user defined function called =ThisSheetname() to accomplish this. I did this to keep the sheet dynamic so that you could copy the index formula from sheet to sheet with out having to hard code the sheet name. But if you want to hard code the sheet name...

    Please Login or Register  to view this content.
    Add this to the Master List Sheet code page.
    Please Login or Register  to view this content.
    Anytime you change the sheet, it will update the validation list, making it automatic.
    Last edited by Tinbendr; 09-09-2014 at 08:19 AM.

  30. #30
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    Ok I got everything working properly but having 2 issues... Where can I change the column that it pulls the vallist from if u can highlight that for me it would be great... Also on the first product it is trimming the first letter so it doesnt locate it if you can tell me how to fix that would be great!!

  31. #31
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    I still cannot get any other sheet to show the correct product list... All of them show all the products instead of just for that plant...

  32. #32
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: For Loop to Add Items to a Listbox!!!

    Quote Originally Posted by cory0789 View Post
    but having 2 issues...
    1. Where can I change the column that it pulls the vallist from if u can highlight that for me it would be great.
    Please Login or Register  to view this content.
    C is the Plant name from Column C. Offset is counting over from that location. In this case, two columns over. So this code is pulling from Column E.

    2. Also on the first product it is trimming the first letter so it doesnt locate it if you can tell me how to fix that would be great!!
    Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    :Slaps forehead:

    Add two lines after this.
    Please Login or Register  to view this content.
    At the very bottom add
    Please Login or Register  to view this content.
    Last edited by Tinbendr; 09-09-2014 at 12:29 PM.

  33. #33
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    Sweet!!!

    Everything works perfectly now I think, ill check it out after work.

    Any chance you can think of a way to copy and paste the orders from the order sheets to a master order sheet... Without copying the blank rows? I tried using count tows in vba but cannot seem to get it to copy only the rows with data.

    Thanks,

  34. #34
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: For Loop to Add Items to a Listbox!!!

    No more than they are, I would just iterate the whole range, testing for "".

    Do you need help with that also?

  35. #35
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    Invoice Testing 0910.xls

    Ok, here is the updated file... Can you look it over and see what I have jacked up to make each sheet not show the proper products? I know they were working before when I transfered all the data but for some reason they all show the same ones now and I am not sure what I did...

    As if I need help with that also... YES, PLEASE if you can help me with that.... The data that goes into the master list does not need to correspond with any of the master list or anything it simply just needs to be a copy and paste frmo the order sheet to the master order list but I dont want any blanks or any junk pasting only the data... if that makes sense...

    Thanks,

  36. #36
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: For Loop to Add Items to a Listbox!!!

    As to why the formulas aren't working, say in Willard. The value in Column A has to match one of those in the validation drop down. If you are adding something new, you'll have to enter it in the master list first, run UpdateValList, then the product will be available in the validation list.

    So, in the Williard worksheet, you have a lot of 991's. But there are no 991's listed for Willard in the Master List.

  37. #37
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    I understand the formulas but the Listboxes in the say Willard sheet are not showing the correct products for Willard plant... It does show the proper ones for Anton and Block 31 but not the Willard ...

  38. #38
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: For Loop to Add Items to a Listbox!!!

    When I d/l the last WB, I had to run UpdateValList. Then they all displayed correctly.

  39. #39
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    O WTH!!!! I swear I ran that piece like 100 times... of course the one time I do it after you say that it worked... FML

    Thanks,

    Should I start a new thread on the copy/paste piece or will it just get deleted?

  40. #40
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: For Loop to Add Items to a Listbox!!!

    Quote Originally Posted by cory0789 View Post
    O WTH!!!! I swear I ran that piece like 100 times..
    Been there, done that!

    The other should be relatively easy, so no, I don't think so.

  41. #41
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    Ok, I have the buttons and the copy and paste working but I just did record macro and its only for the Anton one... It does not take into account any of the blank rows or data I just have it copying and pasting all the rows in the order sheet whether I fill them out or not... I really need it to countrows in vba for the copy and paste part.... I would really like your help doing so... I hope it is easy.



    Just throwing this out there is this possible???
    The master order list sheet I am going to have a custom order # that I put on every order, then when it is returned to me it will have the REAL order # on it... but it will just be the order sheet per plant... Is it possible to make a macro in this file that I can press a button it will locate the Filename of the order sheet find the Custom order # in it compare it to the custom order # column in my worksheet and put the REAL order number wherever the Custom order number is equal from the new sheet to the master orde list???

  42. #42
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    Please Login or Register  to view this content.

  43. #43
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: For Loop to Add Items to a Listbox!!!

    Here's the copy over.
    Please Login or Register  to view this content.
    Last edited by Tinbendr; 09-09-2014 at 05:51 PM.

  44. #44
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    I fail at getting that to work at all, it just pastes a long row in the top row of the master order list sheet...

  45. #45
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    LRMOL in the loop never counts up in the for loop

  46. #46
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    I got it figured out!!!

    Now, I need the tank number to show up properly on the order sheet. Is there a way to make another valist when I click on a product with multiples? Say I click trac107+ at block31 there are like 6 same ones there, can the tank number be a list of which tank it will be delivered too?

    Thanks,

  47. #47
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    I have been trying this for about 2 hours and cannot get anywhere on the coding part... I tried for loops and everything else... Basically I need another update list that updates when the product is selected or the active sheet changes and uses the selection in the product & plant name to make a listbox for the Tank #.... I will continue to try and figure it out and if I do ill post the answer.

  48. #48
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    The following is what I have... what I need is someone to help me put an if statement so the list is only created if the selection in the product box is either 90005 or Trac107+...... can someoen help me put this if statement in there in the proper place....

    2) Is there a way to put an if statement with the Index array formula that is in the cells? I need the tank # to be if product = trac107 or 90005 to go off of the plant location if not leave blank.... or just put the plant location from the master list....

    Thanks,


    Please Login or Register  to view this content.

  49. #49
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: For Loop to Add Items to a Listbox!!!

    tank number to show up properly on the order sheet.
    This is certainly doable, but could you describe the logic, including when no tank is listed.

  50. #50
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    The best way would be if the product selected has multiple locations then make the plant location a dropdown list, if not leave plant location blank but tank number will be the only one available

  51. #51
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: For Loop to Add Items to a Listbox!!!

    (Heavy sigh)

    Quote Originally Posted by cory0789 View Post
    if the product selected has multiple locations
    Are you talking about Master list!Column G?
    then make the plant location a dropdown list, if NOT leave plant location blank but tank number will be the only one available
    And If you have multiple tanks? A validation list in Column H INSTEAD of a Location Column G validation list?

    Now that I think about it, we could add a validation list to each cell with unique values filtered by Plant and Product instead of a formula.

  52. #52
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    Well the only place i need a list will be the location, so based on product selection if the product has multiples then the plant location on order sheet will be a list based on plant location column in master list. Then the formula for tank will need to be where location and product are equal pull tank number. If tgere are no multiple products then just put location and tank number as normal.
    Hopefully that makes sense

  53. #53
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    Ok, to explain further here is the logic... If Product DOES NOT have multiples for that plant then Plant Location Column on order sheet = BLANK & Tank # equals the corresponding tank # for that product. IF product DOES have multiples for that plant then Plant Location becomes a List of Locations with that product & Tank # equals the corresponding tank for that location & that product..... hopefully that makes sense.....
    So for 1720 at Block 31 I simply select 1720 as a product, plant location stays empty and tank# populats.
    For 90005 as a product I select 90005 as a product, plant location becomes a list of locations within that plant that use that product, I select location & Tank # populates accordingly....

    If this is way to complicated let me know

  54. #54
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    Another questin... How can i program the cells to be blank when they = NA so NA doesnt show up on all the index cells...???
    CANCEL THAT IT WAS TOO EASY... Still working on the other its harrrd
    Last edited by cory0789; 09-10-2014 at 11:34 PM.

  55. #55
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: For Loop to Add Items to a Listbox!!!

    Ok, I think I have the solution to #53.

    #54, we probably can just use =IsNA(current formula here). I'm not much of a formula expert. I don't know if this will be the best solution. Might be worth a new thread on this one.

    Can we change the Master List sheet to a Excel Table (Ctrl-T)? Mainly, this will make the formulas dynamic. So as you add/remove rows, the formula ranges won't have to be changed. And it'll only effect the VBA code a little.

  56. #56
    Forum Contributor
    Join Date
    04-14-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    198

    Re: For Loop to Add Items to a Listbox!!!

    Yes whatever is needed to make it better

+ 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] For next loop multiselect activex listbox won't list items in seperate cells. Only 1st
    By Dabbler39 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 08-05-2013, 03:25 PM
  2. [SOLVED] Auto select items in a Listbox with items from another Listbox
    By perducci in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-22-2013, 04:45 PM
  3. Copy Selected items from multicolumn, multiselect listbox to another listbox
    By Willigb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-19-2013, 11:27 AM
  4. Editing listbox items in Dblclick event freezes Excel unless mouse moves over listbox
    By muneebmansoor in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-28-2013, 02:21 PM
  5. Transfer random listbox items to new listbox and then loop through selected items
    By narrowgate88 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-31-2013, 05:58 PM

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