- Excel VBA 質問スレ Part41©2ch.net
220 :デフォルトの名無しさん[sage]:2016/05/13(金) 21:32:30.68 ID:4amCJiHY - >>218
どっちが使いやすいか自分で判断するといい Sub macro() Dim srcRng As Range, fnd As Range Dim firstAddr As String Set srcRng = ActiveSheet.UsedRange Debug.Print "■Findのみ" Set fnd = srcRng.Find("test", LookAt:=xlWhole, SearchDirection:=xlNext) If Not (fnd Is Nothing) Then firstAddr = fnd.Address Do Debug.Print fnd.Address Set fnd = srcRng.Find("test", After:=fnd, LookAt:=xlWhole, SearchDirection:=xlNext) If (fnd Is Nothing) Then Exit Do Loop While (fnd.Address <> firstAddr) End If Debug.Print "■FindNextあり" Set fnd = srcRng.Find("test", LookAt:=xlWhole, SearchDirection:=xlNext) If Not (fnd Is Nothing) Then firstAddr = fnd.Address Do Debug.Print fnd.Address Set fnd = srcRng.FindNext(After:=fnd) If (fnd Is Nothing) Then Exit Do Loop While (fnd.Address <> firstAddr) End If End Sub
|