I have been looking for a way in a previous post to create a macro that involves the use of a loop through the find function that would be something like this:
With ActiveSheet
For i = 1 To LastEntity
Cells.Find(What:="ENTITY(i)", After:=ActiveCell, LookIn:=xlFormulas, _
MatchCase:=False, SearchFormat:=False).Activate
SOME OPERATION
Next i
Here "ENTITY(I)" is meant to mimic the procedure the following code uses to open multiple files:
For i = 1 To .FoundFiles.Count
Set wb = Workbooks.Open(Filename:=.FoundFiles(i))
SOME OPERATION
Next i
My question is: How can this functionality be extended to the find function properly? I am sure that the way I am writing it above is incorrect, but I am also sure there must be a way to do it. Any help would be appreciated!
EDIT:
Would the following change be possible if there was a need for a double loop?
Sub searchRangeAndDoStuff(ByVal ENTITY As String)
Dim xlRange As Excel.Range, varA As Variant, i As Long, x As Long
x = ActiveSheet.Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row
Set xlRange = ActiveSheet.Range(Cells(1, 1), Cells(x, 1))
set varA = xlRange.value
For i = LBound(varA, 1) To UBound(varA, 1)
If InStr(1, varA(i, 1), ENTITY, vbTextCompare) Then
Copy ENTITY
For j = Beginning To End
If InStr(1, varA(j, 1), ITEM, vbTextCompare) Then
Move cells down
Move up one cell
Paste ENTITY
End If
Next j
End If
Next i
End Sub