Hi,

so I'm running a vba script which should change the color of a cell after the user has been modifying the sheet.
The cells the script is coloring in is not protected, but other cells in the same row. (7+)

Without protection the script is running fine, with I'm running into an error (request to debug).
I have no clue why.

Option Explicit

Public Const FirstRowNumber As Long = 16

Sub ColorData(SheetName As String)
   If SheetName = vbNullString Then Exit Sub
   Dim ws As Worksheet, SheetExist As Boolean, I As Long, LastUsedRow, DayString As String
   
   For Each ws In Worksheets
      If ws.Name = SheetName Then
         SheetExist = True
         Exit For
      End If
   Next ws
   If SheetExist = False Then Exit Sub
   
   LastUsedRow = ws.Cells(ws.Rows.Count, 11).End(xlUp).Row

   'Schleife zum Zellen entf?rben
   For I = FirstRowNumber To LastUsedRow
       ws.Range(ws.Cells(I, 3), ws.Cells(I, 6)).Interior.ColorIndex = 2
       ws.Range(ws.Cells(I, 3), ws.Cells(I, 6)).Interior.Pattern = xlSolid
       DayString = ws.Cells(I, 2).Value
       
       Select Case DayString
           Case "":    ws.Range(ws.Cells(I, 3), ws.Cells(I, 6)).Interior.ColorIndex = 36
           Case "HO":  ws.Range(ws.Cells(I, 3), ws.Cells(I, 6)).Interior.ColorIndex = 36
           Case "ho":  ws.Range(ws.Cells(I, 3), ws.Cells(I, 6)).Interior.ColorIndex = 36
           Case "DA":  ws.Range(ws.Cells(I, 3), ws.Cells(I, 6)).Interior.ColorIndex = 36
           Case "da":  ws.Range(ws.Cells(I, 3), ws.Cells(I, 6)).Interior.ColorIndex = 36
           Case "U":   ws.Range(ws.Cells(I, 3), ws.Cells(I, 6)).Interior.Pattern = xlLightUp
           Case "K":   ws.Range(ws.Cells(I, 3), ws.Cells(I, 6)).Interior.Pattern = xlLightUp
           Case "S":   ws.Range(ws.Cells(I, 3), ws.Cells(I, 6)).Interior.Pattern = xlLightUp
           Case "GT":  ws.Range(ws.Cells(I, 3), ws.Cells(I, 6)).Interior.Pattern = xlLightUp
           Case "Sa":  ws.Range(ws.Cells(I, 3), ws.Cells(I, 6)).Interior.Pattern = xlLightUp
           Case "So":  ws.Range(ws.Cells(I, 3), ws.Cells(I, 6)).Interior.Pattern = xlLightUp
           Case Else:  ws.Range(ws.Cells(I, 3), ws.Cells(I, 6)).Interior.Pattern = xlLightUp
      End Select
   Next I
End Sub
I can and will provide any necessary data anybody needs to solve this puzzle.
Hope somebody can help me,
Edward