Comparing two columns and listing differences

  • Thread starter Thread starter gb
  • Start date Start date
G

gb

Hi

In summary, I have two columns (May and April) where the data in each cell
is a string of numbers, mostly all 10-digits long.

The aim was to compare data now (May) to the data from a month ago (April),
in order to work out what data is being queried now that wasn't being
queried one month ago. I hope that makes sense.

Whilst it could be possible to sift through the list and work out what
numbers are new, it would obviously be easier to have a piece of code that
would do it for me. The data I refer to above has been sorted out from a
wider batch of data and refined even further by other code that I use, so it
would make sense to complete the whole thing by means of code.

Anyway, could anyone assist in providing the code that would determine what
numbers exist in the May column that do not exist in the April column and
either:

(a) highlight the new numbers in the May column, or;
(b) copy the new numbers to another column or worksheet/book?

Thank you very much for any help you're able to provide

Thanks

gb
 
Col A Col B
Last Month Data Current Month Data
(Start on current month data)

Sub Macro1()
Do Until ActiveCell.Value = ""
CurrentMonth = Value(ActiveCell.Value)
PriorMonth = Value(ActiveCell.Offset(0, -1).Value)
If CurrentMonth = PriorMonth Then
ActiveCell.Offset(0, 1).Select
ElseIf CurrentMonth < PriorMonth Then
'New value
Selection.Font.Bold = True
ElseIf CurrentMonth > PriorMonth Then
'New value that did not exist in prior month
Selection.Font.Bold = True
End If
Loop
End Sub

Thanks
 
You're the man, Frank!

The 'InOneNotOther command was just the ticket.

Thanks very much indeed!

gb

| Hi
| as a starting point:
| http://www.cpearson.com/excel/duplicat.htm#ExtractingCommon
| http://www.cpearson.com/excel/duplicat.htm#InOneNotOther
|
| --
| Regards
| Frank Kabel
| Frankfurt, Germany
|
|
| gb wrote:
| > Hi
| >
| > In summary, I have two columns (May and April) where the data in each
| > cell is a string of numbers, mostly all 10-digits long.
| >
| > The aim was to compare data now (May) to the data from a month ago
| > (April), in order to work out what data is being queried now that
| > wasn't being queried one month ago. I hope that makes sense.
| >
| > Whilst it could be possible to sift through the list and work out
| what
| > numbers are new, it would obviously be easier to have a piece of code
| > that would do it for me. The data I refer to above has been sorted
| > out from a wider batch of data and refined even further by other code
| > that I use, so it would make sense to complete the whole thing by
| > means of code.
| >
| > Anyway, could anyone assist in providing the code that would
| > determine what numbers exist in the May column that do not exist in
| > the April column and either:
| >
| > (a) highlight the new numbers in the May column, or;
| > (b) copy the new numbers to another column or worksheet/book?
| >
| > Thank you very much for any help you're able to provide
| >
| > Thanks
| >
| > gb
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top