Hi guys
I use the macro below to find the first occurrence of three words. Is there a VBA expert who could modify the code so that it finds all occurrences of three words?
I would be so grateful for your help.
Sub Find_Multiple_Values()
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range
Dim WhatToFind As Variant
Dim iCtr As Long
Dim DestCell As Range
Set wks = ActiveSheet
Set rngToSearch = wks.Columns(5)
WhatToFind = Array("Weekly", "Monthly", "Annually")
For iCtr = LBound(WhatToFind) To UBound(WhatToFind)
With rngToSearch
Set rngFound = .Cells.Find(What:=WhatToFind(iCtr), _
LookIn:=xlValues, LookAt:=xlWhole, _
After:=.Cells(.Cells.Count), _
MatchCase:=False)
If Not rngFound Is Nothing Then
MsgBox rngFound
End If
End With
Next
End Sub
I use the macro below to find the first occurrence of three words. Is there a VBA expert who could modify the code so that it finds all occurrences of three words?
I would be so grateful for your help.
Sub Find_Multiple_Values()
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range
Dim WhatToFind As Variant
Dim iCtr As Long
Dim DestCell As Range
Set wks = ActiveSheet
Set rngToSearch = wks.Columns(5)
WhatToFind = Array("Weekly", "Monthly", "Annually")
For iCtr = LBound(WhatToFind) To UBound(WhatToFind)
With rngToSearch
Set rngFound = .Cells.Find(What:=WhatToFind(iCtr), _
LookIn:=xlValues, LookAt:=xlWhole, _
After:=.Cells(.Cells.Count), _
MatchCase:=False)
If Not rngFound Is Nothing Then
MsgBox rngFound
End If
End With
Next
End Sub