Results 1 to 7 of 7

Sorting within an array, or in a combobox

Threaded View

  1. #1
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Sorting within an array, or in a combobox

    Hello all,
    Anybody out there know if there is a way to sort data in an array, or alternately, to sort in a combobox?

    Here's the situation...
    I have a userform with a combobox. That combobox is being populated by an array, which is storing filenames from a network directory. The code I'm using is below... basically, grabbing filenames from the directory and throwing them into the array. Then when the userform initializes, using that array to populate the combobox.


    Private Sub UserForm_Initialize()
    '' Copied, and only slightly modified code from LaVolpe:  http://www.vbforums.com/showthread.php?t=547296
    Dim sFile As String
    sFile = Dir$("\\corp.bloomberg.com\pn-dfs\global data\research-blaw-profiles\Common\Ask Bloomberg\Custom_Tools\DataSets" & "\*.*", vbDirectory Or vbHidden Or vbSystem Or vbReadOnly Or vbArchive)
    Do Until sFile = vbNullString
        If sFile <> "." Then ' this directory
           If sFile <> ".." Then ' parent directory
              ' add the file to your array here
           End If
        End If
        sFile = Dir$()
        If sFile <> ".." Then ImportDataSet_Form.ComboBox1.AddItem sFile
    
    Loop
    
    
    End Sub
    So, is there a way to alphabatize the filenames, without first writing them to the sheet?

    Thanks for any input!
    Last edited by JP Romano; 05-31-2011 at 09:25 AM. Reason: Solving 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