selection_change adding text to target

  • Thread starter Thread starter Matt Williamson
  • Start date Start date
M

Matt Williamson

Can I use selection_change to modify the current cell?

e.g I want to type 1234 into any cell in column A and have it change to
"Test - 1234 - Test" upon leaving the cell

TIA

Matt
 
Matt,

Copy the code below, right-click the sheet tab, select "View Code" and paste the code into the
window that appears.

I've use the change event because you talk about typing in and not just selecting as cell

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 1 Then Exit Sub
If Target.Cells.Count > 1 Then Exit Sub
If Target.Value = "" Then Exit Sub
Application.EnableEvents = False
Target.Value = "Test - " & Target.Value & " - Test"
Application.EnableEvents = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top