The macro that does what you asked for:
Sub numbers_in_A_not_in_B()
FirstRow = "1"
FirstCol = "A"
SecndCol = "B"
FirstSheet = "Sheet1"
Dim NONO(100)
Dim ABC(100)
' Present setup answers: All the numbers in Column A not present in column B
' reverse computation needs FirstCol = B and SecndCol = A (B and A with
double quotes)
'program is set up for column length of 18. For K = 1 to 18 and for l=1 to
18 and if atable=18 statements
' below ABC(1)= NONO(1) the loops run to 30, the number of numbers in col.A
not in B
Worksheets(FirstSheet).Activate
Kounter = 0
For k = 1 To 18
atable = 0
MyNumberA = Cells(k, FirstCol).Value
For l = 1 To 18
MyNumberB = Cells(l, SecndCol).Value
If MyNumberA = MyNumberB Then
Exit For
Else
atable = atable + 1
End If
Next l
' MsgBox "k l atable" & k & l & atable
If atable = 18 Then
Kounter = Kounter + 1
NONO(Kounter) = MyNumberA
' MsgBox "atable Kounter MyNumberA " & atable & Kounter &
MyNumberA
End If
Next k
ABC(1) = NONO(1)
m = 2
For j = 2 To 30
If NONO(j) <> NONO(j - 1) Then
ABC(m) = NONO(j)
m = m + 1
End If
Next j
For j = 1 To 30
Cells(j, "D") = ABC(j)
Next j
End Sub
Best Regards,
Gabor Sebo