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

Kristina96

New Member
Joined
Sep 30, 2019
Messages
33
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
 

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.
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
 
Upvote 0

Forum statistics

Threads
1,224,885
Messages
6,181,586
Members
453,055
Latest member
cope7895

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top