Solved

How can I identify which values are not in A that are in B?

Posted on 2016-07-15
6
30 Views
Last Modified: 2016-07-15
Attached is a spreadsheet. I need to know what values are in B that are not in A.

Make sense?

Column A represents the files that are in a particular directory with several that were deleted. Column B represents all of the files that SHOULD be in that directory. How can I compare the columns and get a column that represents what's missing in column A?

Thanks!
mp3s.xlsx
0
Comment
Question by:brucegust
  • 4
  • 2
6 Comments
 
LVL 45

Expert Comment

by:Martin Liss
ID: 41713687
Here's a macro you can use. It turns the cells in column B yellow if they aren't in column A.
Sub FindMissing()
Dim lngLastRow As Long
Dim lngRow As Long
Dim rngFound As Range

lngLastRow = Range("B1048576").End(xlUp).Row

Application.ScreenUpdating = False
Columns("A:A").Select
For lngRow = 2 To lngLastRow
    Set rngFound = Selection.Find(What:=Cells(lngRow, "B"), After:=ActiveCell, LookIn:=xlFormulas, LookAt _
        :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False)
    If rngFound Is Nothing Then
        Cells(lngRow, "B").Interior.Color = vbYellow
    End If
Next
Application.ScreenUpdating = True
End Sub

Open in new window

0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 41713688
Just reread your question and this puts the missing values in column C.
Sub FindMissing()
Dim lngLastRow As Long
Dim lngRow As Long
Dim rngFound As Range
Dim lngNR As Long

lngNR = 2
lngLastRow = Range("B1048576").End(xlUp).Row

Application.ScreenUpdating = False
Columns("A:A").Select
For lngRow = 2 To lngLastRow
    Set rngFound = Selection.Find(What:=Cells(lngRow, "B"), After:=ActiveCell, LookIn:=xlFormulas, LookAt _
        :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False)
    If rngFound Is Nothing Then
        Cells(lngNR, "C") = Cells(lngRow, "B")
        lngNR = lngNR + 1
    End If
Next
Application.ScreenUpdating = True
End Sub

Open in new window

0
 

Author Comment

by:brucegust
ID: 41713713
Martin, no doubt this is an elegant piece of syntax, but I'm a pig on roller skates with this kind of stuff.

I've been google-ing to try and figure out how to install your macro and run it, but I'm not finding anything that resonates with what I can understand.

I've got my macro tab. I've found that. How do I take what you did, put it in place and run it?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 41713734
In Excel, Press Alt+F11 to open the Visual Basic Editor (VBE)

Right-click on your workbook name in the "Project-VBAProject" pane (at the top left corner of the editor window). If you don’t see an existing module then select Insert -> Module from the context menu. Otherwise just select the module.

Copy the macro (you can use the ‘Select All’ button if you like) and paste it into the right-hand pane of the VBA editor ("Module1" window)

Press Alt+F11 again to go back to Excel

Optionally, press Alt+F8 to open the "Macro" dialog window. Select the macro, click ‘Options…’,  hold down the Shift key and type the letter A (or any other letter) and click ‘OK’. Then anytime you want to run the macro press Ctrl+Shift+A.

When you close the workbook you will need to save it as an xlsm or xls file if it’s not already one of those.
0
 

Author Closing Comment

by:brucegust
ID: 41713739
Awesome! Thank you!
0
 
LVL 45

Expert Comment

by:Martin Liss
ID: 41713743
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.

Marty - Microsoft MVP 2009 to 2016
              Experts Exchange MVE 2015
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2015
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now