Hi,

If you are using VBA then you may write it as well.

If ActiveCell.Value=ActiveCell.Offset(1,0).Value Then
B=1
Else
B=2
End If

Regards,
Gajendra Gupta