Excel macro; automatically add text to number in column

Closed
pldhrcel Posts 1 Registration date Tuesday December 13, 2016 Status Member Last seen December 13, 2016 - Updated by TrowaD on 19/12/16 at 11:41 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Dec 19, 2016 at 11:44 AM
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
Related:

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Dec 19, 2016 at 11:44 AM
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
0