View Full Version : Solved: Inserting data into the column and maintain it locked
marreco
10-21-2012, 01:41 PM
Hi.
how can I insert data in column 'A' and keep it locked automatically?
the code below to insert the data in column 'A' I need mater ONLY column A locked, but this should be done automatically because kok code vai desbloque it to enter data.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 Then Cells(Target.Row, 1).Value = Date
End Sub
Simon Lloyd
10-21-2012, 04:54 PM
Like this:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 Then Cells(Target.Row, 1).Value = Date
Target.Locked = True
Activesheet.Protect Password:="password"
End Sub
But you will need to make sure all other cells are unlocked otherwise the whole sheet will be protected!
marreco
10-21-2012, 05:03 PM
Hi.
I need only the column 'A' is blocked!
thank you
marreco
10-22-2012, 03:05 PM
HI my frends
Any ideas?
Thank you!!!
Simon Lloyd
10-22-2012, 06:46 PM
Then change target column to 1!!!!
marreco
10-23-2012, 01:38 AM
Hi.
I changed but all cells are locked!
I need only column A is locked, after inserting the data into it.
My code is:
when typing in B2, enter data in A2
when typing in B3, enter data in A3
when typing in B4, A4 insert data in
and so on.
what I need is:
when typing in B2, enter data in A2, which is locked.
unlocks for typing in B3, enter data in A3, which is locked.
unlocks for typing in B4, A4 insert data that is locked.
and so on.
marreco
10-24-2012, 01:52 AM
Hi my frends
Any ideas?
Thank you!!!
Teeroy
10-27-2012, 12:07 AM
Marreco,
Set up the sheet with this code (before protecting it):
Sub sheetSetUp()
Cells.Locked = False
Columns(1).Locked = True
End Sub
Then use this in the sheet code container:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 Then
ActiveSheet.Unprotect Password:="password"
Cells(Target.Row, 1).Value = Date
ActiveSheet.Protect Password:="password"
End If
End Sub
marreco
10-27-2012, 06:00 AM
Hi.
I'm very glad you helped me!
solved my problem so splendid!!
Thank you very much
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.