ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Allow entry only once (https://www.excelbanter.com/excel-programming/330189-allow-entry-only-once.html)

Adam

Allow entry only once
 
Is it possible to set validation/event on every cell in a column that input
can be entered only once, i.e. if I enter 2005-05-26 in a cell it is fixed
and cannot be changed??

Alok

Allow entry only once
 
There can be many ways but one approach could be the following. Paste the
code into the Sheet1's code

Dim rng As Range
Dim bHasValue As Boolean

Private Sub Worksheet_Change(ByVal Target As Range)
If Application.Intersect(Target, rng) Then
If bHasValue Then
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
End If
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
Set rng = Application.Intersect(Target, Sheet1.Columns(1)).Cells(1)
bHasValue = (rng.Value < "")
End Sub

Alok Joshi

"Adam" wrote:

Is it possible to set validation/event on every cell in a column that input
can be entered only once, i.e. if I enter 2005-05-26 in a cell it is fixed
and cannot be changed??



All times are GMT +1. The time now is 07:01 AM.

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