altrox5
09-26-2015, 11:44 AM
Hi,
I have code that should copy the all the values fulfilling the conditions of array:ArrayCh
for some reason, the macro copies only the final result . Is anyone able to help me make the code was copied me all the cells containing the result?
here is the code
Function find_strings_2()
Dim ArrayCh() As Variant
Dim C As Range
Dim firstAddress As String
Dim i As Integer
Dim array_example(10)
ArrayCh = Array("Home", "Home2") 'strings to lookup
With ActiveSheet.Cells
For i = LBound(ArrayCh) To UBound(ArrayCh)
Set C = .Find(What:=ArrayCh(i), LookAt:=xlPart, LookIn:=xlValues)
If Not C Is Nothing Then
firstAddress = C.Address 'used later to verify if looping over the same address
Do
C.Copy
sheet2.Range("A1").PasteSpecial
Set C = .FindNext(C)
Loop While Not C Is Nothing And C.Address <> firstAddress
End If
Next i
End With
End Function
I have code that should copy the all the values fulfilling the conditions of array:ArrayCh
for some reason, the macro copies only the final result . Is anyone able to help me make the code was copied me all the cells containing the result?
here is the code
Function find_strings_2()
Dim ArrayCh() As Variant
Dim C As Range
Dim firstAddress As String
Dim i As Integer
Dim array_example(10)
ArrayCh = Array("Home", "Home2") 'strings to lookup
With ActiveSheet.Cells
For i = LBound(ArrayCh) To UBound(ArrayCh)
Set C = .Find(What:=ArrayCh(i), LookAt:=xlPart, LookIn:=xlValues)
If Not C Is Nothing Then
firstAddress = C.Address 'used later to verify if looping over the same address
Do
C.Copy
sheet2.Range("A1").PasteSpecial
Set C = .FindNext(C)
Loop While Not C Is Nothing And C.Address <> firstAddress
End If
Next i
End With
End Function