Skip to content

Instantly share code, notes, and snippets.

@lporras
Created January 23, 2018 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lporras/f6eb24199ba6aa1fb1dfba293acf7dc1 to your computer and use it in GitHub Desktop.
Save lporras/f6eb24199ba6aa1fb1dfba293acf7dc1 to your computer and use it in GitHub Desktop.
Lock & UnLock Cells visual basic
Sub unlockCells()
'
' unlockcell Macro
'
' Método abreviado de teclado: Opción+Cmd+e
'
Dim chRng As Range
Worksheets("Sheet2").Unprotect ("password")
Set chRng = Worksheets("Sheet2").Range("E1:E100")
For Each chCell In chRng.Cells
chCell.Locked = False
Next chCell
Worksheets("Sheet2").Protect ("password")
End Sub
Sub lockCells()
'
' unlockcell Macro
'
' Método abreviado de teclado: Opción+Cmd+e
'
Dim chRng As Range
Worksheets("Sheet2").Unprotect ("password")
Set chRng = Worksheets("Sheet2").Range("E1:E100")
For Each chCell In chRng.Cells
chCell.Locked = True
Next chCell
Worksheets("Sheet2").Protect ("password")
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment