Comparing two lists

M

Mark

I am using EXCEL 97.

I am wanting to compare two columns of names, if say column 'B' is different
to column 'A' then I want a third column say column 'C' to be created with
the entries which are different.

Can anyone assist me please with some code?
 
C

CoRrRan

I am using EXCEL 97.

I am wanting to compare two columns of names, if say column 'B' is
different to column 'A' then I want a third column say column 'C'
to be created with the entries which are different.

Can anyone assist me please with some code?

Simple piece of code:
*******************************
Sub difference()

Do
With ActiveCell
If .Value = .Offset(0, 1).Value Then
' Whatever you want to do with the difference,
' I used a simple difference sum
.Offset(0, 2).Value = .Value - .Offset(0, 1).Value
End If
.Offset(1, 0).Activate
End With
Loop Until IsEmpty(ActiveCell)

End Sub
********************************

HTH,
CoRrRan
 
A

Amedee Van Gasse

Mark said:
I am using EXCEL 97.

I am wanting to compare two columns of names, if say column 'B' is
different to column 'A' then I want a third column say column 'C' to
be created with the entries which are different.

Can anyone assist me please with some code?

Without VBA, but with a formula:

=A1=B1
and copy down.
Gives you TRUE when they are the same and FALSE if they are not.

Variation:
=IF(A1=B1;"";B1)
and copy down.
Gives you blanks when A and B are equal, and B if they are different.
 
Top