ChristineJ
Well-known Member
- Joined
- May 18, 2009
- Messages
- 775
- Office Version
- 365
- Platform
- Windows
Sample cell contents
G5 contains 10
G6 contains 20
G7 contains 30
G8 contains 40
AA15 contains G5, G6, G7, G8
AB15 contains 10, 15, 20, 35, 40
I've been using the following macro to compare the numbers in cell AB15 to those in cells G5, G6, G7, and G8 --- and to return any where there is not a match into cell AC15. In this example, the result in AC15 would be 15, 35.
Is there a way to convert this to a function that could be entered into cell AC15, such as something like =FindBadNums(AB15)?
Thanks!
G5 contains 10
G6 contains 20
G7 contains 30
G8 contains 40
AA15 contains G5, G6, G7, G8
AB15 contains 10, 15, 20, 35, 40
I've been using the following macro to compare the numbers in cell AB15 to those in cells G5, G6, G7, and G8 --- and to return any where there is not a match into cell AC15. In this example, the result in AC15 would be 15, 35.
Code:
Sub FindBadNums()
Dim A, S, K, T&, Ta&, Op$
S = Split(Range("AA15"), ", ")
A = Split(Range("AB15"), ", ")
For T = 0 To UBound(A)
K = A(T) + 0
For Ta = 0 To UBound(S)
If Range(Trim(S(Ta))) = K Then K = "": Exit For
Next Ta
If K <> "" Then Op = Op & ", " & K
Next T
If Op <> "" Then Range("AC15") = Mid(Op, 2)
End Sub
Is there a way to convert this to a function that could be entered into cell AC15, such as something like =FindBadNums(AB15)?
Thanks!