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
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