|
wgl309 发表于 2012-9-19 21:00
谢谢.很好,运行起来了,如果没有填写时间,能出现担示吗?怎能样提示? - Sub test()
- Dim rw As Long, i As Long, rng As Range
- If Len(Cells(2, 1)) = 0 Or Len(Cells(2, 3)) = 0 Then
- MsgBox "请输入查询日期!", vbCritical + vbOKOnly, "提示"
- Exit Sub
- End If
- rw = Cells(Rows.Count, 1).End(3).Row
- For i = 4 To rw
- If Cells(i, 1) >= Cells(2, 1) And Cells(i, 1) <= Cells(2, 3) Then
- If rng Is Nothing Then
- Set rng = Cells(i, 1)
- Else
- Set rng = Union(rng, Cells(i, 1))
- End If
- End If
- Next
- If Not rng Is Nothing Then rng.EntireRow.Select
- End Sub
复制代码 |
|