Here we show how VBA can be used to lock workbook sheets.
Screenshots
Section titled “Screenshots”
Front Sheet

Monthly Table
VBA Module Code – Locking Sheets
Section titled “VBA Module Code – Locking Sheets”Sub sbProtectSheetJan()
Dim answer As Integeranswer = MsgBox("NOTE:" & Chr(13) & "Are you sure you want to LOCK the submission for January?" & Chr(13) & "You will not be able to unlock the submission after this step.", vbYesNo + vbQuestion, "Please Confirm!")
If answer = vbYes Then
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Summary").Select ActiveSheet.Unprotect "your_sheet_password"
Range("C6").Select ActiveCell.FormulaR1C1 = "ü"
With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With
Selection.Font.Size = 14
With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorAccent6 .TintAndShade = 0.799981688894314 .PatternTintAndShade = 0 End With
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Jan").Select Range("A1").Select MsgBox "January's data has been successfully LOCKED for submission" & Chr(13) & "These records can now be SUBMITTED", vbInformation, "Successfully Locked"
Else 'do nothingEnd If
End Sub
Sub sbProtectSheetFeb()
Dim answer As Integeranswer = MsgBox("NOTE:" & Chr(13) & "Are you sure you want to LOCK the submission for February?" & Chr(13) & "You will not be able to unlock the submission after this step.", vbYesNo + vbQuestion, "Please Confirm!")
If answer = vbYes Then
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Summary").Select ActiveSheet.Unprotect "your_sheet_password"
Range("D6").Select ActiveCell.FormulaR1C1 = "ü"
With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With
Selection.Font.Size = 14
With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorAccent6 .TintAndShade = 0.799981688894314 .PatternTintAndShade = 0 End With
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Feb").Select Range("A1").Select MsgBox "February's data has been successfully LOCKED for submission" & Chr(13) & "These records can now be SUBMITTED", vbInformation, "Successfully Locked"
Else 'do nothingEnd If
End Sub
Sub sbProtectSheetMar()
Dim answer As Integeranswer = MsgBox("NOTE:" & Chr(13) & "Are you sure you want to LOCK the submission for March?" & Chr(13) & "You will not be able to unlock the submission after this step.", vbYesNo + vbQuestion, "Please Confirm!")
If answer = vbYes Then
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Summary").Select ActiveSheet.Unprotect "your_sheet_password"
Range("E6").Select ActiveCell.FormulaR1C1 = "ü"
With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With
Selection.Font.Size = 14
With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorAccent6 .TintAndShade = 0.799981688894314 .PatternTintAndShade = 0 End With
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Mar").Select Range("A1").Select MsgBox "March's data has been successfully LOCKED for submission" & Chr(13) & "These records can now be SUBMITTED", vbInformation, "Successfully Locked"
Else 'do nothingEnd If
End Sub
Sub sbProtectSheetApr()
Dim answer As Integeranswer = MsgBox("NOTE:" & Chr(13) & "Are you sure you want to LOCK the submission for April?" & Chr(13) & "You will not be able to unlock the submission after this step.", vbYesNo + vbQuestion, "Please Confirm!")
If answer = vbYes Then
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Summary").Select ActiveSheet.Unprotect "your_sheet_password"
Range("F6").Select ActiveCell.FormulaR1C1 = "ü"
With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With
Selection.Font.Size = 14
With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorAccent6 .TintAndShade = 0.799981688894314 .PatternTintAndShade = 0 End With
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Apr").Select Range("A1").Select MsgBox "April's data has been successfully LOCKED for submission" & Chr(13) & "These records can now be SUBMITTED", vbInformation, "Successfully Locked"
Else 'do nothingEnd If
End Sub
Sub sbProtectSheetMay()
Dim answer As Integeranswer = MsgBox("NOTE:" & Chr(13) & "Are you sure you want to LOCK the submission for May?" & Chr(13) & "You will not be able to unlock the submission after this step.", vbYesNo + vbQuestion, "Please Confirm!")
If answer = vbYes Then
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Summary").Select ActiveSheet.Unprotect "your_sheet_password"
Range("G6").Select ActiveCell.FormulaR1C1 = "ü"
With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With
Selection.Font.Size = 14
With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorAccent6 .TintAndShade = 0.799981688894314 .PatternTintAndShade = 0 End With
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("May").Select Range("A1").Select MsgBox "May's data has been successfully LOCKED for submission" & Chr(13) & "These records can now be SUBMITTED", vbInformation, "Successfully Locked"
Else 'do nothingEnd If
End Sub
Sub sbProtectSheetJun()
Dim answer As Integeranswer = MsgBox("NOTE:" & Chr(13) & "Are you sure you want to LOCK the submission for June?" & Chr(13) & "You will not be able to unlock the submission after this step.", vbYesNo + vbQuestion, "Please Confirm!")
If answer = vbYes Then
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Summary").Select ActiveSheet.Unprotect "your_sheet_password"
Range("H6").Select ActiveCell.FormulaR1C1 = "ü"
With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With
Selection.Font.Size = 14
With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorAccent6 .TintAndShade = 0.799981688894314 .PatternTintAndShade = 0 End With
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Jun").Select Range("A1").Select MsgBox "June's data has been successfully LOCKED for submission" & Chr(13) & "These records can now be SUBMITTED", vbInformation, "Successfully Locked"
Else 'do nothingEnd If
End Sub
Sub sbProtectSheetJul()
Dim answer As Integeranswer = MsgBox("NOTE:" & Chr(13) & "Are you sure you want to LOCK the submission for July?" & Chr(13) & "You will not be able to unlock the submission after this step.", vbYesNo + vbQuestion, "Please Confirm!")
If answer = vbYes Then
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Summary").Select ActiveSheet.Unprotect "your_sheet_password"
Range("I6").Select ActiveCell.FormulaR1C1 = "ü"
With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With
Selection.Font.Size = 14
With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorAccent6 .TintAndShade = 0.799981688894314 .PatternTintAndShade = 0 End With
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Jul").Select Range("A1").Select MsgBox "July's data has been successfully LOCKED for submission" & Chr(13) & "These records can now be SUBMITTED", vbInformation, "Successfully Locked"
Else 'do nothingEnd If
End Sub
Sub sbProtectSheetAug()
Dim answer As Integeranswer = MsgBox("NOTE:" & Chr(13) & "Are you sure you want to LOCK the submission for August?" & Chr(13) & "You will not be able to unlock the submission after this step.", vbYesNo + vbQuestion, "Please Confirm!")
If answer = vbYes Then
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Summary").Select ActiveSheet.Unprotect "your_sheet_password"
Range("J6").Select ActiveCell.FormulaR1C1 = "ü"
With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With
Selection.Font.Size = 14
With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorAccent6 .TintAndShade = 0.799981688894314 .PatternTintAndShade = 0 End With
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Aug").Select Range("A1").Select MsgBox "August's data has been successfully LOCKED for submission" & Chr(13) & "These records can now be SUBMITTED", vbInformation, "Successfully Locked"
Else 'do nothingEnd If
End Sub
Sub sbProtectSheetSep()
Dim answer As Integeranswer = MsgBox("NOTE:" & Chr(13) & "Are you sure you want to LOCK the submission for September?" & Chr(13) & "You will not be able to unlock the submission after this step.", vbYesNo + vbQuestion, "Please Confirm!")
If answer = vbYes Then
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Summary").Select ActiveSheet.Unprotect "your_sheet_password"
Range("K6").Select ActiveCell.FormulaR1C1 = "ü"
With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With
Selection.Font.Size = 14
With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorAccent6 .TintAndShade = 0.799981688894314 .PatternTintAndShade = 0 End With
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Sep").Select Range("A1").Select MsgBox "September's data has been successfully LOCKED for submission" & Chr(13) & "These records can now be SUBMITTED", vbInformation, "Successfully Locked"
Else 'do nothingEnd If
End Sub
Sub sbProtectSheetOct()
Dim answer As Integeranswer = MsgBox("NOTE:" & Chr(13) & "Are you sure you want to LOCK the submission for October?" & Chr(13) & "You will not be able to unlock the submission after this step.", vbYesNo + vbQuestion, "Please Confirm!")
If answer = vbYes Then
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Summary").Select ActiveSheet.Unprotect "your_sheet_password"
Range("L6").Select ActiveCell.FormulaR1C1 = "ü"
With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With
Selection.Font.Size = 14
With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorAccent6 .TintAndShade = 0.799981688894314 .PatternTintAndShade = 0 End With
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Oct").Select Range("A1").Select MsgBox "October's data has been successfully LOCKED for submission" & Chr(13) & "These records can now be SUBMITTED", vbInformation, "Successfully Locked"
Else 'do nothingEnd If
End Sub
Sub sbProtectSheetNov()
Dim answer As Integeranswer = MsgBox("NOTE:" & Chr(13) & "Are you sure you want to LOCK the submission for November?" & Chr(13) & "You will not be able to unlock the submission after this step.", vbYesNo + vbQuestion, "Please Confirm!")
If answer = vbYes Then
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Summary").Select ActiveSheet.Unprotect "your_sheet_password"
Range("M6").Select ActiveCell.FormulaR1C1 = "ü"
With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With
Selection.Font.Size = 14
With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorAccent6 .TintAndShade = 0.799981688894314 .PatternTintAndShade = 0 End With
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Nov").Select Range("A1").Select MsgBox "November's data has been successfully LOCKED for submission" & Chr(13) & "These records can now be SUBMITTED", vbInformation, "Successfully Locked"
Else 'do nothingEnd If
End Sub
Sub sbProtectSheetDec()
Dim answer As Integeranswer = MsgBox("NOTE:" & Chr(13) & "Are you sure you want to LOCK the submission for December?" & Chr(13) & "You will not be able to unlock the submission after this step.", vbYesNo + vbQuestion, "Please Confirm!")
If answer = vbYes Then
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Summary").Select ActiveSheet.Unprotect "your_sheet_password"
Range("N6").Select ActiveCell.FormulaR1C1 = "ü"
With Selection .HorizontalAlignment = xlCenter .VerticalAlignment = xlBottom .WrapText = False .Orientation = 0 .AddIndent = False .IndentLevel = 0 .ShrinkToFit = False .ReadingOrder = xlContext .MergeCells = False End With
Selection.Font.Size = 14
With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorAccent6 .TintAndShade = 0.799981688894314 .PatternTintAndShade = 0 End With
ActiveSheet.Protect "your_sheet_password", True, True
Sheets("Dec").Select Range("A1").Select MsgBox "December's data has been successfully LOCKED for submission" & Chr(13) & "These records can now be SUBMITTED", vbInformation, "Successfully Locked"
Else 'do nothingEnd If
End SubDownload
Section titled “Download”The full file can be downloaded here: