View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ryan H Ryan H is offline
external usenet poster
 
Posts: 489
Default Need help with locking columns

You can run this code, but you really don't have too. I would just select
the Columns A,F,H and righ click, then select Format Cells, click Protection,
ensure locked cells has a check mark in it. The protect the sheet and save,
you are then done!

Sub LockColumns()

' protect worksheet
ActiveSheet.Unprotect Password:="password"

' unlock all cells
Cells.Locked = False

' lock Columns A,F,H
Range("A:A,F:F,H:H").Locked = True

' protect worksheet
ActiveSheet.Protect Password:="password"
End Sub

--
Cheers,
Ryan


"Al" wrote:

I am trying to lock columns A, F, and H on Sheet1 so that when a user opens
the workbook, these 3 columns are locked for any editing, however, I want the
user to be able to edit any thing else on the sheet. I need help with the
code.
thanks
Al