|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
黑仔 发表于 2013-11-26 17:46
可以成功互交,但还是有问题,当a列有两个相同的曰期时就不成功,我要的是当我在ListView查找到后点击后跳 ...
Find方法循环查找:- Private Sub ListView1_Click()
- Dim c As Range, rngU As Range, m&, firstAddress$
- With Range("a:a")
- Set c = .Find(DateValue(ListView1.SelectedItem.Text), , xlFormulas, xlWhole) '查找日期
- If Not c Is Nothing Then
- firstAddress = c.Address
- Do
- m = m + 1
- If m = 1 Then Set rngU = c Else Set rngU = Union(rngU, c)
- Set c = .FindNext(c)
- Loop While Not c Is Nothing And c.Address <> firstAddress
- End If
- End With
- If m > 0 Then
- rngU.Select
- Unload Me '关闭窗体
- ' Me.Hide '或用隐藏窗体
- Else
- MsgBox "没有查到。", vbInformation
- End If
- End Sub
复制代码 |
|