Try the following code in a standard module:-
Dim lr As Long
lr = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To lr
If Cells(i, 2).Value = Cells(i, 1).Value Then
Cells(i, 2) = "-" & Cells(i, 1).Value
It should do the task for you.
Following is a link to my test work book for you to see and try. Just click on the button to see it work:-
I hope that this helps.