Locking cels using a UDF
Can't do it with a function, but with event code
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "G2:H2000"
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
.Locked = True
End With
End If
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
Bob Phillips
(remove nothere from email address if mailing direct)
"Viral" <u16718@uwe wrote in message news:58ec62eb8a08e@uwe...
I'm not entirely sure if this is possible or not... but here we go.
I'm looking to lock down two cells in a row after data is input into the
cells... for the entire spreadsheet... or at least 2000 rows. I think the
easiest way would be to have a function since I could fill down and the
two
cells would change relative to the position of the function.
Basically, I'm looking to lock cells A1:B1 and so on all the way down the
spreadsheet. I've seen some subroutines to lock cells, but I don't know
how
to use them in the spreadsheet, and I'm having a heck of a time trying to
get
this to work.
I'd appreciate any help. Thanks.
|