Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I've got a list of names that I want to put into a drop-down - in
Alphabetical order... I know, I could put them into a sheet, sort them then add them into the drop-down, but... Is there a clever way that I can get them in order without dumping them all out, sorting them and bringing them back in? Thanks M |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Michelle,
I don't know if what I have below is more efficient than moving the list to a sheet and making Excel perform the sort. I used the original version in a vbScript within an HTA where I didn't have Excel to rely on. In the example below, the original list is in A1:A10 on the active sheet and it isn't alphabetized. The list is retrieved, alphabetized and used to populate combobox1 in a user form. '----------------------------------------- Private Sub UserForm_Activate() Const adVarChar = 200 Const MaxCharacters = 255 Dim R As Integer Set DataList = CreateObject("ADOR.Recordset") DataList.Fields.Append "MyList", adVarChar, MaxCharacters DataList.Open For R = 1 To 10 DataList.AddNew DataList("MyList") = Cells(R, 1).Value DataList.Update Next R DataList.Sort = "MyList" DataList.MoveFirst Do Until DataList.EOF ComboBox1.AddItem DataList.Fields.Item("MyList") DataList.MoveNext Loop Set DataList = Nothing End Sub '----------------------------------------- Steve Yandl "Michelle" wrote in message ... I've got a list of names that I want to put into a drop-down - in Alphabetical order... I know, I could put them into a sheet, sort them then add them into the drop-down, but... Is there a clever way that I can get them in order without dumping them all out, sorting them and bringing them back in? Thanks M |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It does exactly what I want!
M "Steve Yandl" wrote in message ... Michelle, I don't know if what I have below is more efficient than moving the list to a sheet and making Excel perform the sort. I used the original version in a vbScript within an HTA where I didn't have Excel to rely on. In the example below, the original list is in A1:A10 on the active sheet and it isn't alphabetized. The list is retrieved, alphabetized and used to populate combobox1 in a user form. '----------------------------------------- Private Sub UserForm_Activate() Const adVarChar = 200 Const MaxCharacters = 255 Dim R As Integer Set DataList = CreateObject("ADOR.Recordset") DataList.Fields.Append "MyList", adVarChar, MaxCharacters DataList.Open For R = 1 To 10 DataList.AddNew DataList("MyList") = Cells(R, 1).Value DataList.Update Next R DataList.Sort = "MyList" DataList.MoveFirst Do Until DataList.EOF ComboBox1.AddItem DataList.Fields.Item("MyList") DataList.MoveNext Loop Set DataList = Nothing End Sub '----------------------------------------- Steve Yandl "Michelle" wrote in message ... I've got a list of names that I want to put into a drop-down - in Alphabetical order... I know, I could put them into a sheet, sort them then add them into the drop-down, but... Is there a clever way that I can get them in order without dumping them all out, sorting them and bringing them back in? Thanks M |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On 27 Mai, 14:29, "Michelle" wrote:
I've got a list of names that I want to put into a drop-down - in Alphabetical order... I know, I could put them into a sheet, sort them then add them into the drop-down, but... Is there a clever way that I can get them in order without dumping them all out, sorting them and bringing them back in? Thanks M Hello Michelle, Sorting with worksheet functions: http://sulprobil.com/html/sorting.html Regards, Bernd |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Where, what ,how is the list of names? Are they in an Array? How many dimensions? Are they in a collection? Are they in a Dictionary? Are they in something else? Why do you want to avoid the Excel worksheet sort? It is one of the fastest available. How many names approximately are there? 20, 2000, 200000? What operating system and Excel version are you using? -- Jim Cone Portland, Oregon USA (Special Sort... http://www.contextures.com/excel-sort-addin.html ) "Michelle" wrote in message ... I've got a list of names that I want to put into a drop-down - in Alphabetical order... I know, I could put them into a sheet, sort them then add them into the drop-down, but... Is there a clever way that I can get them in order without dumping them all out, sorting them and bringing them back in? Thanks M |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Where are you getting the names from??
"Michelle" wrote: I've got a list of names that I want to put into a drop-down - in Alphabetical order... I know, I could put them into a sheet, sort them then add them into the drop-down, but... Is there a clever way that I can get them in order without dumping them all out, sorting them and bringing them back in? Thanks M |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
alphabetical order | Excel Discussion (Misc queries) | |||
Sorting in Custom Alphabetical Order | Excel Worksheet Functions | |||
Sorting Cells in Alphabetical Order by Last Name | Excel Discussion (Misc queries) | |||
sorting letters in words into alphabetical order | Excel Discussion (Misc queries) | |||
Sorting Worksheets in Alphabetical Order (Left to Right) | Excel Programming |