vba 中findnext怎样才能嵌套使用?

 我来答
帐号已注销
2011-08-02 · TA获得超过8615个赞
知道大有可为答主
回答量:3242
采纳率:66%
帮助的人:2936万
展开全部
findnext的使用条件:搜索的 单元格区域、内容、其他设置 都与前面的find相同
例如:

Public Sub iFind()
Dim c As Range, rng As Range, s$, iAdd$, msg$, n&
Set rng = Range("A:A")
s = "abc"
With rng
Set c = .Find(s, .Cells(.Cells.Count), xlValues, xlWhole)
If Not c Is Nothing Then
iAdd = c.Address(0, 0)
Do
n = n + 1
msg = msg & vbCrLf & c.Address(0, 0)
Set c = .FindNext(c) '条件不变,使用FindNext
If c Is Nothing Then Exit Do
Loop Until iAdd = c.Address(0, 0)
End If
End With
MsgBox "完成!共找到 " & n & " 个“" & s & "”:" & vbCrLf & msg
End Sub
追问
问题没有描述清楚。
2个findnext如何嵌套使用。
谢谢!
find(a)
find(b)
findnext(b)
findnext(a)
追答
findnext是根据前一个find或findnext来的,嵌套不了
相当于 复制和粘贴,复制一次,后面一直可以粘贴,但是只能有一次复制,不能嵌套
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式