Automatically Add Word to Cell When Text Entered

Nate123

New Member
Joined
Oct 8, 2010
Messages
8
I am trying to find a way to automatically add a word to the end of a string when someone enters something into a cell in column A. For example, if I enter '123123' the macro would add 'Test' to the end resulting in '123123 Test'. However, if I enter '123123 Test' it would leave the cell alone and not add another 'Test' to the end. I am looking for a way to have this done when a person edits a cell and not have to run a macro from the macro menu each time. Any ideas?
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Maybe something along these lines ( put code in the worksheet module)

Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

    Dim i As Long

    With Target
        If .Column = 1 Then
            For i = 1 To .Cells.Count
            If UCase(Right(.Cells(i), 4)) <> UCase("Test") And _
            Not IsEmpty(.Cells(i)) Then
                .Cells(i) = .Cells(i) & " Test"
            End If
            Next i
        End If
    End With

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,259
Members
452,901
Latest member
LisaGo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top