I want to protect a worksheet so that certain cells can't be edited, when I protect the sheet the I get the a run-time error when I click the next and previous buttons on my excel.
The code is below, what do I have to do so that it will work when protected?
Thanks in advance.
The code is below, what do I have to do so that it will work when protected?
Thanks in advance.
Code:
Sub PreviousMonth()
If ActiveSheet.Range("A3").Value = 1 Then
Exit Sub
Else:
Range("A3").Value = Range("A3").Value - 1
LeaveTracker.Columns("B:NI").Hidden = True
LeaveTracker.Range(Columns(Range("A3").Value * 31 - 29), Columns(Range("A3").Value * 31 + 1)).Hidden = False
End If
End Sub
Sub NextMonth()
If ActiveSheet.Range("A3").Value = 12 Then
Exit Sub
Else:
Range("A3").Value = Range("A3").Value + 1
LeaveTracker.Columns("B:NI").Hidden = True
LeaveTracker.Range(Columns(Range("A3").Value * 31 - 29), Columns(Range("A3").Value * 31 + 1)).Hidden = False
End If
End Sub