|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Private Sub CommandButton3_Click()
Dim arr, brr, t, i&, j&, r&, u&
Dim rr()
ReDim rr(1 To 4, 1 To 3)
If Trim(TextBox6.Text) <> "" Then
n = n + 1
rr(n, 1) = TextBox6.Text
rr(n, 2) = 4
End If
If Trim(TextBox5.Text) <> "" Then
n = n + 1
rr(n, 1) = TextBox5.Text
rr(n, 2) = 8
End If
If Trim(TextBox7.Text) <> "" Then
nn = nn + 1
ks = CDate(TextBox7.Text)
End If
If Trim(TextBox8.Text) <> "" Then
nn = nn + 1
js = CDate(TextBox8.Text)
End If
If n = "" And nn = "" Then MsgBox "请至少输入一个查询条件!": Exit Sub
With Sheets("Sheet1")
r = .Cells(Rows.Count, 1).End(xlUp).Row
arr = .Range("a1:o" & r)
End With
ReDim brr(1 To UBound(arr), 1 To 5)
For i = 2 To UBound(arr)
sl = 0: m = 0
For s = 1 To n
mc = rr(s, 1)
lh = rr(s, 2)
If Trim(arr(i, lh)) = Trim(mc) Then
m = m + 1
End If
Next s
If m = n Then
If nn = "" Then
k = k + 1
brr(k, 1) = arr(i, 3)
brr(k, 2) = arr(i, 4)
brr(k, 3) = arr(i, 8)
brr(k, 4) = arr(i, 11)
brr(k, 5) = arr(i, 13)
ElseIf nn <> "" Then
If Trim(arr(i, 3)) <> "" Then
If IsDate(arr(i, 3)) Then
If nn = 1 Then
If arr(i, 3) >= ks Then
k = k + 1
brr(k, 1) = arr(i, 3)
brr(k, 2) = arr(i, 4)
brr(k, 3) = arr(i, 8)
brr(k, 4) = arr(i, 11)
brr(k, 5) = arr(i, 13)
End If
ElseIf nn = 2 Then
If arr(i, 3) >= ks And arr(i, 3) <= js Then
k = k + 1
brr(k, 1) = arr(i, 3)
brr(k, 2) = arr(i, 4)
brr(k, 3) = arr(i, 8)
brr(k, 4) = arr(i, 11)
brr(k, 5) = arr(i, 13)
End If
End If
End If
End If
End If
End If
Next i
If k = "" Then MsgBox "没有符合条件的数据!": Exit Sub
mr = Array(3, 4, 8, 11, 13)
With ListView1
.ListItems.Clear
.View = lvwReport
.FullRowSelect = True
.Gridlines = True
For i = 1 To k
Set t = .ListItems.Add(, , brr(i, 1))
For j = 2 To UBound(brr, 2)
t.ListSubItems.Add , , brr(i, j)
Next j
Next i
End With
End Sub
|
评分
-
1
查看全部评分
-
|