Excel macro; automatically add text to number in column

Closed
Report
Posts
1
Registration date
Tuesday December 13, 2016
Status
Member
Last seen
December 13, 2016
-
Posts
2829
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
November 22, 2021
-
Hello,
I am a newbie in excel macro's and I was wondering if anyone could help me.
I want to write a macro who once I write a number in a cell of colom for example: J
it automatically fills de cel with the number + the word "failed"

any help would be welcom
Thx

1 reply

Posts
2829
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
November 22, 2021
490
Hi pldhrcel,

Try the following code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Columns("J:J")) Is Nothing Then Exit Sub
If Target.Cells.Count > 1 Then Exit Sub
If Target.Value = vbNullString Then Exit Sub
If IsNumeric(Target.Value) = True And Right(Target.Value, 5) <> "Failed" Then
    Target.Value = Target.Value & " Failed"
End If
End Sub


Right-click the sheets tab and select View Code, the paste the code in the big white field. Now enter a number in column J and see what happens.

Best regards,
Trowa