|
问题一,查找- Private Sub CommandButton1_Click()
- Dim dateStart As Date
- Dim dateEnd As Date
- If Me.DTPicker2.Value < Me.DTPicker1.Value Then
- MsgBox "结束时间小于起始时间"
- Exit Sub
- End If
- dateStart = Me.DTPicker1.Value
- dateEnd = Me.DTPicker2.Value
- ListView1.ListItems.Clear
- With Sheets("sheet1")
- For i = 4 To .[B65536].End(xlUp).Row
- If InStr(.Cells(i, 3), TextBox1.Text) And InStr(.Cells(i, 6).Value, TextBox2.Text) > 0 And .Cells(i, 8) >= dateStart And .Cells(i, 8) <= dateEnd Then
- Set itm = ListView1.ListItems.Add()
- itm.Text = .Cells(i, 2)
- itm.SubItems(1) = .Cells(i, 3)
- itm.SubItems(2) = .Cells(i, 4)
- itm.SubItems(3) = .Cells(i, 5)
- itm.SubItems(4) = .Cells(i, 6)
- itm.SubItems(5) = .Cells(i, 7)
- itm.SubItems(6) = .Cells(i, 8)
- itm.SubItems(7) = .Cells(i, 9)
- End If
- Next i
- If ListView1.ListItems.Count = 0 Then MsgBox "未查询到相关记录!", 64, "结果"
- End With
- End Sub
复制代码 |
|