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!
Bookmarks