Lock The Required Range

    Lock the required Range and Unlock the remaining worksheet by using VBA Macros

  • used LOCKED Property of Worksheet
  • used PROTECT Method of worksheet
  •  

     

    Download The Workbook

     

    Sub Protect_The_Required_Range_Or_Cells()

    'Unlock the entire worksheet
    ActiveSheet.Cells.Locked = False

    'Lock the required range
    ActiveSheet.Range("D4:F9").Locked = True

    'Protect worksheet
    ActiveSheet.Protect "abcd"

    End Sub

    Sub Unlock_The_Worksheet()
    'unlock the data
    ActiveSheet.Unprotect "abcd"

    End Sub