ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   program cell to display any character when cell is active (https://www.excelbanter.com/excel-programming/351565-program-cell-display-any-character-when-cell-active.html)

David is learning

program cell to display any character when cell is active
 
In Excel, I would like a cell to automatically insert a letter when it is
clicked or active.

Norman Jones

program cell to display any character when cell is active
 
Hi David,

Try:
'=============
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const myLetter As String = "Z"
Const sAddress As String = "A1"

If Not Intersect(Range(sAddress), Target) Is Nothing Then
Range(sAddress).Value = myLetter
End If
End Sub
'<<=============

This is worksheet event code and should be pasted into the worksheets's code
module (not a standard module and not the workbook's ThisWorkbook module):

Right-click the worksheet's tab
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman



"David is learning" <David is wrote in
message ...
In Excel, I would like a cell to automatically insert a letter when it is
clicked or active.





All times are GMT +1. The time now is 09:39 AM.

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