+ Reply to Thread
Results 1 to 15 of 15

Filter and Sort Scripting Dictionary

  1. #1
    Registered User
    Join Date
    05-18-2011
    Location
    Fort Worth, TX
    MS-Off Ver
    Excel 2010
    Posts
    13

    Filter and Sort Scripting Dictionary

    I'm having an issue filtering and sorting a scripting dictionary. The macro I am using creates a dictionary and displays it on a userform. However, there repeated values in the dictionary, and the values are not in alphabetical order. Is it possible to do put the values in alphabetical order and remove the duplicates? Any help is appreciated.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Filter and Sort Scripting Dictionary

    You could use a collection as described here: http://spreadsheetpage.com/index.php..._unique_items/

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    05-18-2011
    Location
    Fort Worth, TX
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Filter and Sort Scripting Dictionary

    Dom,

    Thanks for the quick reply. Looks like this will work, but I have one further question. Where would I integrate this function? To be honest, I'm pretty green when it comes to VBA. I added the code from your link, and integrated the relevant parts to my macro, but I get the error "type mismatch". Here's what I have thus far.

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Filter and Sort Scripting Dictionary

    hi Jbryce22, as a suggestion: if you are allowed to change the order of the range ("D4103" ...) rows you can sort it before proceeding with dupes elimination

  5. #5
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Filter and Sort Scripting Dictionary

    I was meaning to use that instead of the scripting dictionary.

    Which line is giving the error?

    Dom

  6. #6
    Forum Contributor
    Join Date
    04-03-2011
    Location
    India
    MS-Off Ver
    Excel 2015
    Posts
    122

    Re: Filter and Sort Scripting Dictionary

    Hi,

    Please upload your sample workbook to do vba activity.

  7. #7
    Registered User
    Join Date
    05-18-2011
    Location
    Fort Worth, TX
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Filter and Sort Scripting Dictionary

    Here's my workbook. Any help is greatly appreciated.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    05-18-2011
    Location
    Fort Worth, TX
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Filter and Sort Scripting Dictionary

    Watersev,

    That is one way to do it, but I would prefer to have that done in the scripting dictionary if possible. I'd rather not have to sort the data source unless there is no other way to accomplish this.

  9. #9
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Filter and Sort Scripting Dictionary

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    05-18-2011
    Location
    Fort Worth, TX
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Filter and Sort Scripting Dictionary

    Kenneth, thanks for this. I'm having trouble integrating this. Is this supposed to be in lieu of my current macro, or in addition to? I'm not very well versed in VBA, and I apologize if this is annoying. I just really want to get this to work. Thanks!

    Please Login or Register  to view this content.

  11. #11
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Filter and Sort Scripting Dictionary

    It should probably go something like:
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    05-18-2011
    Location
    Fort Worth, TX
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Filter and Sort Scripting Dictionary

    Kenneth, again, thanks for your help. I wasn't able to get this to work. It's still not sorting or filtering. Do you have any other suggestions?

  13. #13
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Filter and Sort Scripting Dictionary

    I am not sure what you mean by filter.

    Your original code eliminates dups. My sort routine sorts it. You need to move your data out of sort order to see that. Of course your routine is only doing it for the first combobox. I am not why you resized the range to 3 if you only wanted the Column A data for combobox1.

  14. #14
    Registered User
    Join Date
    05-18-2011
    Location
    Fort Worth, TX
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Filter and Sort Scripting Dictionary

    My apologies. I think I misscommunicated. The reason I have my range set to 3 is because I would like for combobox2 to include the 3rd column in my data range (Manager). I should have clarified better my needs. I was hoping to have combobox2 sorted and the dupes removed from it. Using your quicksort, I am able to sort the combobox2, but I am unsure of how to remove the duplicates from it. Again, any help is appreciated. Many thanks, Kenneth.

  15. #15
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Filter and Sort Scripting Dictionary

    You have some other issues after selecting the first one but this fills and sorts both comboboxes.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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