|
发表于 2014-11-9 13:43
|
显示全部楼层
本楼为最佳答案
Private Sub CommandButton1_Click()
ListView1.ListItems.Clear
If TextBox1 & TextBox2 & TextBox3 & TextBox4 & TextBox5 & TextBox6 = "" Then
MsgBox "请至少输入一个查询条件"
Exit Sub
End If
With Sheets("数据库")
For RowIndex = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
If (.Cells(RowIndex, 1) Like "*" & TextBox1 & "*" Or TextBox1 = "") _
And (.Cells(RowIndex, 2) Like TextBox2 + "*" Or TextBox2 = "") _
And (.Cells(RowIndex, 3) Like UCase(TextBox3) + "*" Or TextBox3 = "") _
And (.Cells(RowIndex, 4) Like TextBox4 + "*" Or TextBox4 = "") _
And (.Cells(RowIndex, 5) Like TextBox5 + "*" Or TextBox5 = "") _
And (.Cells(RowIndex, 13) Like TextBox6 + "*" Or TextBox6 = "") Then
Set lst = ListView1.ListItems.Add(, , .Cells(RowIndex, 1))
lst.SubItems(1) = .Cells(RowIndex, 2)
lst.SubItems(2) = .Cells(RowIndex, 3)
lst.SubItems(3) = .Cells(RowIndex, 4)
lst.SubItems(4) = .Cells(RowIndex, 5)
lst.SubItems(5) = .Cells(RowIndex, 6)
lst.SubItems(6) = Format(.Cells(RowIndex, 7), "#,##0.00")
lst.SubItems(7) = Format(.Cells(RowIndex, 8), "#,##0.00")
lst.SubItems(8) = Format(.Cells(RowIndex, 9), "#,##0.00")
lst.SubItems(9) = Format(.Cells(RowIndex, 10), "#,##0.00")
lst.SubItems(10) = Format(.Cells(RowIndex, 11), "#,##0.00")
lst.SubItems(11) = Format(.Cells(RowIndex, 12), "#,##0.00")
lst.SubItems(12) = .Cells(RowIndex, 13)
lst.SubItems(13) = .Cells(RowIndex, 14)
lst.SubItems(14) = RowIndex
total = total + .Cells(RowIndex, 7)
End If
Next
Label9.Caption = "共找到 " & ListView1.ListItems.Count & " 条记录"
Label10.Caption = "总费用: " & Format(total, "#,##0.00")
Set dic = Nothing
End With
End Sub
粘错位置了,重新改一下 |
评分
-
查看全部评分
|