There may be easier methods, but I'd do something like this:
I'm filling the arrays with your values; you can fill them however you want to the key is the comparisons in the loop, notice the string will not get written to C if it's not equal or if it's 0.
Sub CompareArrays()
Dim A(0 To 8) As Integer
Dim B(0 To 8) As Integer
Dim C As String
Dim X As Integer
Dim Y As Integer
A(0) = 0
A(1) = 0
A(2) = 0
A(3) = 4
A(4) = 0
A(5) = 0
A(6) = 7
A(7) = 8
A(8) = 9
'{0, 0, 0, 4, 0, 0, 7, 8, 9}
B(0) = 1
B(1) = 0
B(2) = 0
B(3) = 4
B(4) = 0
B(5) = 0
B(6) = 0
B(7) = 0
B(8) = 9
'{1, 0, 0, 4, 0, 0, 0, 0, 9}
For X = 0 To 8
For Y = 0 To 8
If A(X) = B(Y) And A(X) <> 0 Then
C = C & " " & A(X)
End If
Next Y
Next X
MsgBox C
End Sub
Bookmarks