|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
116632880 发表于 2014-4-19 14:24
按楼上的代码修改后,功能完成了一半,但是日期是按照年代和月排序的,在一个月内的日期还没有排序,
所以 ...
代码作了修改:
Private Sub TextBox1_Change()
Dim a(), m%
On Error Resume Next
If TextBox1.Text = "" Then
Call zb
Else
ReDim a(1 To ListBox1.ListCount, 1 To 14)
For i = 1 To ListBox1.ListCount
If InStr(ListBox1.List(i - 1, 12), TextBox1.Text) > 0 Then
m = m + 1
For j = 1 To 14
a(m, j) = ListBox1.List(i - 1, j - 1)
Next j
End If
Next i
End If
ListBox1.List = a
End Sub
Private Sub UserForm_Initialize()
Dim arr, b, c
ListBox1.ColumnWidths = "90,150,40,50,60,0,0,0,70,0,0,80,120,40"
Call zb
End Sub
Public Function zb()
Me.ListBox1.Height = 300 ' 设置列表框的高度
Myr = Sheets("录入表").Range("c65536").End(xlUp).Row ' 信息表的最后一行行号
ar = Sheets("录入表").Range("a3:n" & Myr) ' 信息表的数据区域
ListBox1.ColumnCount = UBound(ar, 2) ' 设定listbox表中的列数
Me.ListBox1.List = ar ' 将信息表的数据全部显示到列表框中
ListBox1.List = Array_Sort(ListBox1.List, 0, 2)
ReDim b(1 To ListBox1.ListCount, 1 To 14)
ReDim c(1 To ListBox1.ListCount, 1 To 14)
For i = 1 To ListBox1.ListCount
If Day(Val(ListBox1.List(i - 1, 1))) > 9 Then
m = m + 1
For j = 1 To 14
b(i, j) = ListBox1.List(i - 1, j - 1)
Next j
Else
n = n + 1
For j = 1 To 14
c(i, j) = ListBox1.List(i - 1, j - 1)
Next j
End If
Next i
For i = m + 1 To m + n
For j = 1 To 14
b(i, j) = c(i - m - 1, j - 1)
Next j
Next i
ListBox1.List = b
End Function |
|