ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   enter text in cell just by selecting cell (https://www.excelbanter.com/excel-programming/402806-enter-text-cell-just-selecting-cell.html)

dlyon

enter text in cell just by selecting cell
 
When i select a cell i would like the letter X or a number to automatically
insert.

Mark Ivey

enter text in cell just by selecting cell
 
Reference the following thread:

"Macro to Enter text" from 12/13/2007





"dlyon" wrote in message
...
When i select a cell i would like the letter X or a number to
automatically
insert.




Gord Dibben

enter text in cell just by selecting cell
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "A1:A10"
Dim cell As Range

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
For Each cell In Target
cell.Value = "X"
Next cell
End If

ws_exit:
Application.EnableEvents = True
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code"

Copy/paste into that sheet module. Alt + q to return your sheet.

Adjust the range A1:A10 and the value "X" to suit.


Gord Dibben MS Excel MVP

On Sat, 15 Dec 2007 10:10:01 -0800, dlyon
wrote:

When i select a cell i would like the letter X or a number to automatically
insert.




All times are GMT +1. The time now is 12:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com