Search worksheets for items in a column and report anything missing

AndyMb

New Member
Joined
Jul 1, 2015
Messages
20
Hi all,

I am looking for a macro that will look down a list and report anything that's not on the list.

My list is on Sheet1 in column A
Starting with the value of cell A1 I want to search 3 sheets, "AttendanceA", "AttendanceB" and "Returns".
There might be multiple instances of the search string, however I'm only interested if there are no matches.
If there is No match, i'd like to paste that unmatched value to a list in a separate sheet.
I would then like to search the next item down on the list (A2) and repeat the search, again adding the item to the unmatched list if not found.
and so on until the end of the list.

Any help appreciated
regards
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
How about
VBA Code:
Sub AndyMb()
    Dim Ary As Variant, Shts As Variant
    Dim i As Long, r As Long
    
    Shts = Array("AttendanceA", "AttendanceB", "Returns")
    With CreateObject("scripting.dictionary")
        Ary = Sheets("Sheet1").Range("A1").CurrentRegion.Value2
        For r = 1 To UBound(Ary)
            .Item(Ary(r, 1)) = Empty
        Next r
        For i = 0 To UBound(Shts)
            Ary = Sheets(Shts(i)).Range("A1").CurrentRegion.Value2
            For r = 1 To UBound(Ary)
                If .exists(Ary(r, 1)) Then .Remove Ary(r, 1)
            Next r
        Next i
        Sheets("Sheet2").Range("A1").Resize(.Count).Value = Application.Transpose(.keys)
    End With
End Sub
This assumes all values are in col A
 
Upvote 0
How about
VBA Code:
Sub AndyMb()
    Dim Ary As Variant, Shts As Variant
    Dim i As Long, r As Long
   
    Shts = Array("AttendanceA", "AttendanceB", "Returns")
    With CreateObject("scripting.dictionary")
        Ary = Sheets("Sheet1").Range("A1").CurrentRegion.Value2
        For r = 1 To UBound(Ary)
            .Item(Ary(r, 1)) = Empty
        Next r
        For i = 0 To UBound(Shts)
            Ary = Sheets(Shts(i)).Range("A1").CurrentRegion.Value2
            For r = 1 To UBound(Ary)
                If .exists(Ary(r, 1)) Then .Remove Ary(r, 1)
            Next r
        Next i
        Sheets("Sheet2").Range("A1").Resize(.Count).Value = Application.Transpose(.keys)
    End With
End Sub
This assumes all values are in col A
Works perfectly, thank you!
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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