Your can probably use the following Code. Sub LockMacro()
Dim dt As Date Dim i As Integer Dim nr As Integer Dim r As Range i = 6 'range->F While Cells(4, i) <> "" And Cells(1, i) < dt '---Row4 i = i + 1 Wend Set r = Range(Cells(1, 1), Cells(30, i - 1)) r.Locked = True End Sub Akhilesh On Wed, Aug 10, 2011 at 4:20 AM, AJ <laxplaya000...@gmail.com> wrote: > There are dates in calendar order stored in row 4, beginning in column > F through column BR. How can I write a code so that it locks a > certain amount of cells below the date if it occurs in the past. For > example: January 14th is in cell O4. If todays date was January > 14th, i would want to lock all cells within the range F4:O21 > > Thanks in advance for the help, > > AJ > > -- > > ---------------------------------------------------------------------------------- > Some important links for excel users: > 1. Follow us on TWITTER for tips tricks and links : > http://twitter.com/exceldailytip > 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 > 3. Excel tutorials at http://www.excel-macros.blogspot.com > 4. Learn VBA Macros at http://www.quickvba.blogspot.com > 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com > > To post to this group, send email to excel-macros@googlegroups.com > > <><><><><><><><><><><><><><><><><><><><><><> > Like our page on facebook , Just follow below link > http://www.facebook.com/discussexcel > -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel