0
我正在尝试使组合框从某个范围中获取其值。我只想看到唯一的值,它必须按字母顺序排序(不区分大小写)。对combobox中的数据进行排序不区分大小写
一切工作正常,除了数据的排序。排序是区分大小写的,但这不是我想要的。
排序是这样的:
Door
Room
Window
kitchen
但方式我想它:
Door
kitchen
Room
Window
下面你可以找到我的代码:
Dim x, a, b As Long, c As Variant
Dim DataRng As String
Worksheets("House").Activate
'Unique Records
For x = 2 To Cells(Rows.Count, 4).End(xlUp).Row
If WorksheetFunction.CountIf(Range("D2:D" & x), Cells(x, 4)) = 1 Then
ComboBox1.AddItem Cells(x, 4).Value
End If
Next
'Alphabetic Order
For a = 0 To ComboBox1.ListCount - 1
For b = a To ComboBox1.ListCount - 1
If ComboBox1.List(b) < ComboBox1.List(a) Then
c = ComboBox1.List(a)
ComboBox1.List(a) = ComboBox1.List(b)
ComboBox1.List(b) = c
End If
Next
Next
End Sub
我希望有人能解决我的问题或者可以给我一个提示。
尝试'UCASE(ComboBox1.List(B))...'或'选项比较text'也许 –
谢谢,它的工作。如此简单(一旦你知道如何去做:-))我将我的代码改为:如果UCase(ComboBox1.List(b))
AVB