ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   how can i lock cell immediately if any value Entered? (https://www.excelbanter.com/new-users-excel/41434-how-can-i-lock-cell-immediately-if-any-value-entered.html)

Sureshsmartdc

how can i lock cell immediately if any value Entered?
 
I want lock a cell immediately when i entered a value. So that the user cant
change the value what he entered. But it should be done automatically. The
very next process of his entry it should be done.

JethroUK©

not practical - you will type mistakes (i was going to say 'might')

you would need a macro to lock cells as you type, and when you finished
choose:

ToolsProtectionProtect Sheet

to disable all locked cells

"Sureshsmartdc" wrote in message
...
I want lock a cell immediately when i entered a value. So that the user

cant
change the value what he entered. But it should be done automatically. The
very next process of his entry it should be done.




Gary's Student

Here is an example of pseudo-protecting a cell. This macro looks for changes
to cell A1. The first time data is entered, the Macro "remembers" the value.
If A1 changes after that, the macro will detect the change and restore A1 to
the "remembered" value. You can adapt it to your needs. The Macro should go
into the Worksheet code area.


Dim sval As Variant
Dim i As Integer
Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Range("A1:A1"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
If i = 0 Then
i = 1
sval = Range("A1:A1").Value
Else
Range("a1:a1").Value = sval
End If
Application.EnableEvents = True
End Sub

--
Gary's Student


"JethroUK©" wrote:

not practical - you will type mistakes (i was going to say 'might')

you would need a macro to lock cells as you type, and when you finished
choose:

ToolsProtectionProtect Sheet

to disable all locked cells

"Sureshsmartdc" wrote in message
...
I want lock a cell immediately when i entered a value. So that the user

cant
change the value what he entered. But it should be done automatically. The
very next process of his entry it should be done.






All times are GMT +1. The time now is 11:29 AM.

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