+ Reply to Thread
Results 1 to 19 of 19

Remove Items from Combobox if selected in Another Combobox

  1. #1
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Remove Items from Combobox if selected in Another Combobox

    I Am looking for a way to remove an item from the other comboboxes if selected in another. The basic setup is that when the userform loads it adds the same items to all 4 comboboxes.... What I need to do is have it remove from the other 3 comboboxes if selected in any of the 4 comboboxes.... then if the selection changes re-add the previously selected item back to the other comboboxes. I uploaded a sample sheet with my failed attempt at it.
    Attached Files Attached Files
    Bramz

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Remove Items from Combobox if selected in Another Combobox

    Something like this:

    Please Login or Register  to view this content.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Remove Items from Combobox if selected in Another Combobox

    You could probably do this in one routine but is a little more complicated code, this is simple and straight forward

  4. #4
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Re: Remove Items from Combobox if selected in Another Combobox

    Keebellah,

    I need it to populate all the comboboxes on opening of the form and the Items that are added to it are file names that are stored on a share drive... I just used the ABC's as a filler for the sample file

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Remove Items from Combobox if selected in Another Combobox

    Okay, clear.
    I would suggest then that you first read the list of files into an array and apply the same method.
    Dose this mean that the list may vary ?

  6. #6
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Re: Remove Items from Combobox if selected in Another Combobox

    List will not vary. Not quite sure how to use an array that's why I tend to shy away from using them

  7. #7
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Remove Items from Combobox if selected in Another Combobox

    can the user select any combobox or does the user start with the topmost and then the next ?

  8. #8
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Re: Remove Items from Combobox if selected in Another Combobox

    They can start with any combobox.
    Found this UDF to create the Array.... Over on http://forums.devshed.com/visual-bas...ue-342763.html

    Not sure if its a step in the right direction or not
    Please Login or Register  to view this content.
    Last edited by meabrams; 07-26-2017 at 02:56 AM. Reason: fix way link is displayed

  9. #9
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Remove Items from Combobox if selected in Another Combobox

    This can be used, but the fact that the user may select any combobox at will makes the coding it a little more complicated

  10. #10
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Remove Items from Combobox if selected in Another Combobox

    Just curious, is there any special reason why you have named the comboboxes as you did? Why start with m3 and not m1?
    If I understood you correctly the user may start with any box.
    My idea would be start with the first and then allow the second one etc etc.

  11. #11
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Re: Remove Items from Combobox if selected in Another Combobox

    direct relation to the label on the userform... just didn't include the labels

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Remove Items from Combobox if selected in Another Combobox

    Okay, understood, I'll see if I can put together a basic working routine for you.
    The rest you can always edit and tweak

  13. #13
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Re: Remove Items from Combobox if selected in Another Combobox

    Thank you for you help so far on this

  14. #14
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Remove Items from Combobox if selected in Another Combobox

    Try example file. After changing all 4 Combo's you have to push Reset button to start over again.
    Attached Files Attached Files
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  15. #15
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Remove Items from Combobox if selected in Another Combobox

    I did not include the rest button but this is my idea, I have not looked at @bakerman2 's solution
    Attached Files Attached Files

  16. #16
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Remove Items from Combobox if selected in Another Combobox

    P.S. You will have to chang the filepath used

  17. #17
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Re: Remove Items from Combobox if selected in Another Combobox

    Keebellah'

    your way works, but if the user select an item for all them then decides to change there mind the available options do not update...

    bakerman2,

    your way does remove the item, but I need it to add it back if the user decides to change their mind hopefully with out the use of a rest button.

    The Item do not have to be in the same order if that's not a possibility

  18. #18
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Remove Items from Combobox if selected in Another Combobox

    I modified it adding @bakerman2's button and reset button.
    Don't forget the filepath
    Attached Files Attached Files

  19. #19
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Re: Remove Items from Combobox if selected in Another Combobox

    So here's what I have come up with (a lot of it is form google searches) that works to add/remove items from all the comboboxes on the userform.... Its not as I had hoped in that it does not place them back in the same order but I'm not sure if that is possible or how much work that is going to be...

    Please take a look at it and let me know if there is anyway that it can be made better.

    I will leave this thread opened for a few more days then mark solved there is no more movement on it....

    Once again thank you both for your input
    Attached Files Attached Files

+ 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. UserForm ComboBox ONLY display selected items in List
    By onmyway in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-16-2015, 01:02 PM
  2. [SOLVED] Userform - ListBox items added based on Combobox value selected
    By jayherring86 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 11-12-2014, 09:12 AM
  3. How to remove duplicate items from the Combobox
    By kerznerk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-22-2014, 01:26 AM
  4. Populating Userform ComboBox Using Items from Content Control Combobox
    By anarxo in forum Word Programming / VBA / Macros
    Replies: 2
    Last Post: 01-17-2014, 01:00 PM
  5. Replies: 3
    Last Post: 04-02-2013, 06:02 PM
  6. Remove Combobox Duplicated items
    By D_Rennie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-25-2009, 02:35 AM
  7. ComboBox to determine selected items
    By qiqinuinaifen128 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-02-2009, 06:27 AM

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