Conditional Cell Protection

  • Thread starter Thread starter Joe Delaney
  • Start date Start date
J

Joe Delaney

I need to be able to prevent any other information being entered in a
column once one cell has been entered.

For example if someone inputs information into cell A1, I do not want
anyone else to be able to enter anything anywhere else in Column A or
for there to be a warning before they do so.

Is this possible?
 
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ans As Long
On Error GoTo ws_exit:
Application.EnableEvents = False
With Target
If Application.CountA(.EntireColumn) > 0 Then
ans = MsgBox("Data already present" & vbNewLine & _
"ARe you sre?", vbYesNo)
If ans <> vbYes Then
.Value = ""
End If
End If
End With

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top