Select Columns based on date in 2nd row

I am working in Excel 2010.
I have a worksheet where, from columns 4-100, in the second row, I have a date (e.g. 12/24/2011). Columns 4 to 8 have a date value of '12/12/2011' in row 2, Columns 9 to 12 have a value of 12/13/2011' in row 2, and so on.
I need to lock the columns based on the date in the second row. For instance, when it's December 20th, I am going to want to lock the columns where the cell in row 2 contains a date less than 12/20/2011. I know this is probably pretty easy, but I'm still getting the hang of the lookup functions. What is the correct formula in VBA for select the columns as specified here?
Thanks,
  Todd
LVL 7
shambaladAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

shambaladAuthor Commented:
It occurs to me I am actually asking 2 questions here. I would like to focus on the column selection for this question. I am going to open another question about locking a selection of cells.
0
Curt LindstromCommented:
try this

 For i=4 to 400            
  If Format(Worksheets("Sheet1").Cells(2, i), "dd/mm/yy") < Format(Now, "dd/mm/yy") Then
  'Do something
  End If
 Next

Curt
0
Curt LindstromCommented:
For US dates use

 For i=4 to 400            
  If Format(Worksheets("Sheet1").Cells(2, i), "mm/dd/yy") < Format(Now, "mm/dd/yy") Then
  'Lock column i
  End If
 Next

Also, change "Sheet1" to whatever your sheet name is.

Cheers,
Curt
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shambaladAuthor Commented:
Thank you,
Todd
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.