Excel [Closed]

Report
-
Posts
1260
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
February 3, 2020
-
Hello,

if the column a and column b are equal, i want to put "-"(minus sign) before the data of column b for further technical purpose.
eg. it looks like tiger tiger, i want to put minus symbol infront of column b tiger, so it should look like -tiger in column b.
plz tell me how to do it...

1 reply

Posts
1260
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
February 3, 2020
213
Hello BKP,

Try the following code in a standard module:-

Sub Test()

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
    End If
Next

End Sub


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:-

https://www.dropbox.com/s/bdi5r4hqwkmhggw/BKP.xlsm?dl=0

I hope that this helps.

Cheerio,
vcoolio.

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!