Vba question on creating a function that compares two arrays

jd556

New Member
Joined
Apr 17, 2013
Messages
2
Hey guys my assignment is to create a VBA function that takes in two arrays and spits out the unique names that are not in both arrays.

This is what I have so far but I am running into many issues (including 'Run-Time Error 9")
I am fairly new to VBA so any help would be greatly appreciated!!

Function UniqueNames(astrArray1() As String, astrArray2() As String) As String
Dim i As Long
Dim o As Long
For i = LBound(astrArray1) To UBound(astrArray1)
If astrArray1(i) <> astrArray2(i) Then
findUniques = findUniques & i & ","
End If
Next
For o = LBound(astrArray2) To UBound(astrArray2)
If astrArray1(o) <> astrArray2(o) Then
findUniques = findUniques & astrArray2(o) & ","
End If
Next o

End Function
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,203,472
Messages
6,055,612
Members
444,803
Latest member
retrorocket129

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