|
楼主 |
发表于 2011-1-16 21:17
|
显示全部楼层
增加按选择频次排序功能
在其他帖子里看到有些同学提到最好通实现按选择频次进行排序功能,也就是说选择次数多的选项排在前面,仔细想了下,还是能实现的,具体修改了以下代码就能实现。
Private Sub ListBox2_DblClic
k(ByVal Cancel As MSForms.ReturnBoolean)
On Error Resume Next
ActiveCell.Value = Right(ListBox2.Value, Len(ListBox2.Value) - InStr(1, ListBox2.Value, "-"))
Cells(ActiveCell.Row, ActiveCell.Column + 1).Value = Left(ListBox2.Value, InStr(1, ListBox2.Value, "-") - 1)
'每选择一次列表选项后,被选择的列表项选择频次加1,并按选择频次进行排序
With Sheet3
.Cells(Application.Match(ListBox2.Value, .Range("D:D"), 0), 6).Value = .Cells(Application.Match(ListBox2.Value, .Range("D:D"), 0), 6).Value + 1
' .Range("A1").Select
.Range("A1:G" & .Range("D65536").End(xlUp).Row).Sort Key1:=.Range("F2"), Order1:=xlDescending, Key2:= _
.Range("G2"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom, SortMethod:=xlPinYin, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal
End With
Me.TextBox2 = ""
Me.ListBox2.Visible = False
Me.TextBox2.Visible = False
End Sub
供大家参考! |
评分
-
1
查看全部评分
-
|