View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
SK8 SK8 is offline
external usenet poster
 
Posts: 2
Default Lock Cells Dependent on Prior Months

Please help, I'm working on a project to design a new forecast template and I
need to be able to lock a range of cells dependent on a given month. For
instance

A1 = Target Month

Range K9 : V9 has the 12 months of the year where K9 = Jan 2010, L9 = Feb
2010 ... V9 = Dec 2010

As the months in the year move along, I'd like to lock all prior months for
the corresponding cell months for rows 18-251. So if the Target Month (A1)
is April 2010, then I'd like to lock cells K9:M251. In essence I'd like to
restrict users from unintentionally changing actual data and only input their
new forecast for the upcoming months.

I took a couple of stabs at it and tried the following code, but was still
missing something. Any help would be greatly appreciated.

Private Sub Worksheet_Change(ByVal Target As Range)

If K9 <= A1 Then
Range("K11:K251").Locked = True
End If
End Sub