Får fejl, når regneark er beskyttet.
Hej igen,jeg har et efterhånden rimeligt avanceret regneark med en vagttørn - se dette spørgsmål:
http://www.exp.dk/spm/668656
Det hele kører sådan set perfekt nu, men hvis jeg vil beskytte mit ark (Makér ulåste celler), så får jeg en fejl, hvis jeg forsøger at køre makroen "MarkerHelligdage()". Makroen til "MarkerHelligdage()" ser sådan ud:
*************
Public Sub MarkerHelligdage()
For Each c In Range(" B2:AF2").Cells
If IsDate(c) Then
If ErHelligdag(c) Then
Range(Cells(3, c.Column), Cells(8, c.Column)).Interior.ColorIndex = 15
Range(Cells(11, c.Column), Cells(16, c.Column)).Interior.ColorIndex = 15
Range(Cells(19, c.Column), Cells(24, c.Column)).Interior.ColorIndex = 15
Range(Cells(27, c.Column), Cells(32, c.Column)).Interior.ColorIndex = 15
Range(Cells(35, c.Column), Cells(40, c.Column)).Interior.ColorIndex = 15
Range(Cells(42, c.Column), Cells(43, c.Column)).Interior.ColorIndex = 15
Range(Cells(45, c.Column), Cells(46, c.Column)).Interior.ColorIndex = 15
Range(Cells(48, c.Column), Cells(48, c.Column)).Interior.ColorIndex = 15
Else
Range(Cells(3, c.Column), Cells(8, c.Column)).Interior.ColorIndex = xlNone
Range(Cells(11, c.Column), Cells(16, c.Column)).Interior.ColorIndex = xlNone
Range(Cells(19, c.Column), Cells(24, c.Column)).Interior.ColorIndex = xlNone
Range(Cells(27, c.Column), Cells(32, c.Column)).Interior.ColorIndex = xlNone
Range(Cells(35, c.Column), Cells(40, c.Column)).Interior.ColorIndex = xlNone
Range(Cells(42, c.Column), Cells(43, c.Column)).Interior.ColorIndex = xlNone
Range(Cells(45, c.Column), Cells(46, c.Column)).Interior.ColorIndex = xlNone
Range(Cells(48, c.Column), Cells(48, c.Column)).Interior.ColorIndex = xlNone
End If
Else
Range(Cells(3, c.Column), Cells(8, c.Column)).Interior.ColorIndex = xlNone
Range(Cells(11, c.Column), Cells(16, c.Column)).Interior.ColorIndex = xlNone
Range(Cells(19, c.Column), Cells(24, c.Column)).Interior.ColorIndex = xlNone
Range(Cells(27, c.Column), Cells(32, c.Column)).Interior.ColorIndex = xlNone
Range(Cells(35, c.Column), Cells(40, c.Column)).Interior.ColorIndex = xlNone
Range(Cells(42, c.Column), Cells(43, c.Column)).Interior.ColorIndex = xlNone
Range(Cells(45, c.Column), Cells(46, c.Column)).Interior.ColorIndex = xlNone
Range(Cells(48, c.Column), Cells(48, c.Column)).Interior.ColorIndex = xlNone
End If
Next
End Sub
*************
Det er en VB-fejl, hvor der bare står "400" i advarslen!
Hvordan kan jeg markere helligdagene, samtidig med, at mit regneark er beskyttet?
