I have a spreadsheet that includes command buttons used to run macros for calculations. I have a macro that is used to lock the worksheet and protect it, i want the command buttons with the macros for the calculations to be be disabled when the lock worksheet macro is run. Can anyone help me with this:

My code is:


Public Sub unlocksheet()
'unlock the worksheet

On Error Resume Next
ActiveSheet.Unprotect Password:="HCAI"

End Sub
Public Sub locksheet()
'lock the worksheet

On Error Resume Next
ActiveSheet.Protect Password:="HCAI"

End Sub


Sub calculateYearlyQuarter()

' Lr = "Last Row"

    Dim Lr As Long
     
    Lr = Range("I" & Rows.Count).End(xlUp).Row
    
'Refers to Cells 1 = "1" and 5 = Column "E"
     
    With Cells(2, 39).Resize(Lr - 1, 1)
        .Formula = "=""Q""&INT(1+MOD(MONTH(I2)-1,12)/3)"
        .Font.ColorIndex = 3
        .Font.Bold = True
    End With

End Sub

Sub calculateFinancialQuarter()

' Lr = "Last Row"

    Dim Lr As Long
     
    Lr = Range("I" & Rows.Count).End(xlUp).Row

'Refers to Cells 1 = "1" and 6 = Column "F"
    
    With Cells(2, 40).Resize(Lr - 1, 1)
        .Formula = "=""Q""&INT(1+MOD(MONTH(I2)-4,12)/3)"
        .Font.ColorIndex = 3
        .Font.Bold = True
    End With
    
End Sub