+ Reply to Thread
Results 1 to 8 of 8

Create unique list using Dictionary Object in Combobx 2 based off selection of Combobox 1

  1. #1
    Registered User
    Join Date
    10-23-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Create unique list using Dictionary Object in Combobx 2 based off selection of Combobox 1

    In my effort to figure out how to populate a combobox with only the unique values from a worksheet list, I have discovered the Dictionary Object structure.
    The following link has been helpful to show how this can be used to fill a combobox:
    http://www.ozgrid.com/forum/showthread.php?t=39750

    However this is for the initialize userform event. What I need is to have this dictionary object be applied to a second combobox ("CbxCity") that is filled based on the selection of a first comobox ("CbxAssetType2"). My code thus far does not seem to be correct but I am not sure why:

    Please Login or Register  to view this content.
    I tried using
    Please Login or Register  to view this content.
    for the first If statement however that does not do anything either.. Any help is greatly appreciated!

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Create unique list using Dictionary Object in Combobx 2 based off selection of Combob

    How is the code not working?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    10-23-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Create unique list using Dictionary Object in Combobx 2 based off selection of Combob

    It gives an "Object with variable or With Block variable not set" error when I select an entry in the first combobox. The
    Please Login or Register  to view this content.
    is highlighted and x gives a null when clicked.

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Create unique list using Dictionary Object in Combobx 2 based off selection of Combob

    x isn't a range:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-23-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Create unique list using Dictionary Object in Combobx 2 based off selection of Combob

    Awesome, thanks I knew it was something simple I was over looking!

  6. #6
    Registered User
    Join Date
    10-23-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Create unique list using Dictionary Object in Combobx 2 based off selection of Combob

    Actually, I overlooked how I would use the second combobox ("CbxCity") after I got it filled with unique values. Originally it was being filled by numbers from an ID column in my table, which would reference the row number in the table. However, how can I set up this second combobox to have a second column that also grabs the corresponding value/number in the "ID#" column of my table?

  7. #7
    Registered User
    Join Date
    10-23-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Create unique list using Dictionary Object in Combobx 2 based off selection of Combob

    For example, to fill the two column combobox I would do so through the following code (note the column position of the offset- grabs the "ID#" column in relation to the "Asset" column used in the code above):
    Please Login or Register  to view this content.
    However in this case, since Me.CbxCity.List is set to equal dic.keys, I am not sure how to reference the second column of the combobox and set it to equal (0,-2) position corresponding to i.value?

  8. #8
    Registered User
    Join Date
    10-23-2012
    Location
    Washington, DC
    MS-Off Ver
    Excel 2010
    Posts
    43

    Re: Create unique list using Dictionary Object in Combobx 2 based off selection of Combob

    It appears that since dic.Keys is in fact generated as an object and not a direct reference to the sheet rows/columns, there is no way to grab corresponding column values using this method...

+ 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: 07-27-2013, 10:11 PM
  2. Phone list based on combobox selection !
    By Petter120 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-18-2013, 04:00 AM
  3. [SOLVED] ComboBox when external value change other combobx return Value
    By feroguz in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-14-2013, 04:33 PM
  4. VBA: Create unique list based on latest entry in list
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-08-2011, 09:55 AM
  5. Replies: 1
    Last Post: 12-01-2010, 04:51 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