Comparing two arrays and go to if-condition if match was found

Kristina96

New Member
Joined
Sep 30, 2019
Messages
31
Hello,
I have two arrays Arr1 and Arr2 that both include a list of words.
I need a code that compares every element of Arr1 with every element of Arr2. If at least one match was found I wan't to add more code.
So it would look like this:

If Arr1=Arr2 Then
...

The comparing part is not working yet. Do you have any ideas on this?
Thank you in advance,
Kristina
 

Some videos you may like

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Akuini

Well-known Member
Joined
Feb 1, 2016
Messages
2,571
Office Version
365
Platform
Windows
Try something like this:
VBA Code:
Dim flag As Boolean
flag = False
For Each a In arr1
    For Each b In arr2
       If a = b Then flag = True: GoTo skip:
    Next
Next
skip:
If flag = True Then
'...
End If
 

Watch MrExcel Video

Forum statistics

Threads
1,099,082
Messages
5,466,537
Members
406,485
Latest member
kaksolver

This Week's Hot Topics

Top