Assuming:
- both your columns are actually numbers formatted as text (as per the leading zeros)
- You need to return
TRUE or FALSE as per your statement: "....Therefore both of these should return "true"
You could decide not to iterate over column B again and again. Instead you can perform a Find looking for values within values of column B:
Sample Code:
Sub Test() Dim lr1 As Long, lr2 As Long, x As Long Dim arr As Variant Dim rng As Range, cl As Range With Sheet1 'Change according to your sheets CodeName 'Fill the array for a loop in memory lr1 = .Cells(.Rows.Count, 1).End(xlUp).Row arr = .Range("A1:A" & lr1) 'Get the range to look in lr2 = .Cells(.Rows.Count, 2).End(xlUp).Row Set rng = .Range("B1:B" & lr2) 'Loop over the array and perform the search For x = LBound(arr) To UBound(arr) Set cl = rng.Find(arr(x, 1), LookIn:=xlValues) If Not cl Is Nothing Then .Cells(x, 3) = True 'If you want to insert boolean value '.Cells(x,3) = cl 'If you want to insert the found value '.Cells(x,3) = arr(x,1) 'If you want to insert the search value Else .Cells(x, 3) = False End If Next End With End Sub
Another way would be to work through memory without Find:
Sub Test() Dim lr1 As Long, lr2 As Long, x As Long Dim arr1 As Variant, arr2 As Variant, arr3 As Variant With Sheet1 'Change according to your sheets CodeName 'Fill the first array for a loop in memory lr1 = .Cells(.Rows.Count, 1).End(xlUp).Row arr1 = .Range("A1:A" & lr1) 'Fill the second array for a filter lr2 = .Cells(.Rows.Count, 2).End(xlUp).Row arr2 = Application.Transpose(Application.Index(.Range("B1:B" & lr2), 0, 1)) 'Loop over the array and perform the search For x = LBound(arr1) To UBound(arr1) 'Return an array of filtered values arr3 = Filter(arr2, arr1(x, 1)) 'Do something with the returned array If UBound(arr3) > -1 Then .Cells(x, 3) = True 'If you want to insert boolean value '.Cells(x,3) = arr3(1) 'If you want to insert the found value '.Cells(x, 3) = Join(arr3, ",") 'if you want to show all found values '.Cells(x,3) = arr(x,1) 'If you want to insert the search value Else .Cells(x, 3) = False End If Next End With End Sub
In both cases you might want to make sure you also format column C as text.