PDA

View Full Version : Allow Auto Data Entry into a locked cell.



Silverfox123
01-14-2019, 10:59 AM
Hello there

i have a column which when either “decide” / “undecided” is selected from a drop down menu it auto populates another column next to it with a date.

The problem is when I lock the cell as I don’t want anyone to put data in themselves, the locked cell does not allow the auto data that I have requested.

Hiw is can I get round this.

ta

MartinGM
01-14-2019, 11:43 AM
. . . it auto populates another column next to it with a date.

How is this "auto populate" being done ?

Silverfox123
01-14-2019, 12:01 PM
On my workbook Column K auto populates with the date and time if column N has any data selected in it, selected by the user. I don't want users to be able to put any data in themselves, however if I lock the cell it wont auto populate? Can the cell be locked but still allow auto data?


The code I have is:


Private Sub Worksheet_Change(ByVal Target As Range)

Dim xCellColumn As Integer
Dim xTimeColumn As Integer
Dim xRow, xCol As Integer
Dim xDPRg, xRg As Range
xCellColumn = 14
xTimeColumn = 11
xRow = Target.Row
xCol = Target.Column
If Target.Text <> "" Then
If xCol = xCellColumn Then
Cells(xRow, xTimeColumn) = Now()
Else
On Error Resume Next
Set xDPRg = Target.Dependents
For Each xRg In xDPRg
If xRg.Column = xCellColumn Then
Cells(xRg.Row, xTimeColumn) = Now()
End If
Next
End If
End If
End Sub

p45cal
01-17-2019, 06:47 AM
A quick and dirty solution might be
Me.Protect userinterfaceonly:=True
as the first line of the sub.