I am running a workbook which is processing data, and placing it in a new workbook.
The new workbook has two sheets, and it needs to have VBA code loaded for the Worksheet_Change macro, and into a module.

The code is loading correctly, using

Code:
    ' Copy this code into Worksheet Main
    TheItem = 2
    If WB.VBProject.VBComponents.Item(TheItem).Properties("Name").Value <> "Main" Then
        TheItem = 3
    End If

    WB.VBProject.VBComponents.Item(TheItem).CodeModule.InsertLines 2, "Private Sub Worksheet_Change(ByVal Target As Range)"
    WB.VBProject.VBComponents.Item(TheItem).CodeModule.InsertLines 3, "    If Not ThisWorkbook.Worksheets(Module1.CMSht).Cells(2,11).Value Then ' WorkInProgress"
    WB.VBProject.VBComponents.Item(TheItem).CodeModule.InsertLines 4, "        ThisWorkbook.Worksheets(Module1.CMSht).Cells(2,11).Value = True ' WorkInProgress"
However when I have the new workbook open, and make a change on the relevant sheet I have a problem.
The first line of the below macro executes and it moves onto the next line
ThisWorkbook.Worksheets(Module1.CMSht).Cells(2, 11).Value = True ' WorkInProgress
however when I press F8 on this line the debugger then halts.
The same happens if I run it normally.

I have tried inserting a line reading Debug.Print "Test", which works fine, but it still fails on the original line

Any suggestions?
Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not ThisWorkbook.Worksheets(Module1.CMSht).Cells(2, 11).Value Then ' WorkInProgress
        ThisWorkbook.Worksheets(Module1.CMSht).Cells(2, 11).Value = True ' WorkInProgress
        Select Case Target.Column
        Case 3, 4
            If Target.Row > 2 Then
                Target.Interior.ColorIndex = ColourMapping(Target.Value)
            End If
        Case 5
            If Target.Row > 2 Then
                If Target.Value = "" Then
                    Target.Interior.ColorIndex = 0
                Else
                    Target.Interior.ColorIndex = ColourMapping("Red")
                End If
            End If
        Case 6
            If Target.Row > 2 Then
                If Target.Value = "" Then
                    Target.Interior.ColorIndex = 0
                Else
                    If Target.Offset(0, -1).Value <> "" Then
                        Target.Offset(0, -1).Value = ""
                        Target.Offset(0, -1).Interior.ColorIndex = 0
                    End If
                    Target.Interior.ColorIndex = ColourMapping("Amber")
                End If
            End If
        Case 7
            If Target.Row > 2 Then
                If Target.Value = "" Then
                    Target.Interior.ColorIndex = 0
                Else
                    If Target.Offset(0, -1).Value <> "" Then
                        Target.Offset(0, -1).Value = ""
                        Target.Offset(0, -1).Interior.ColorIndex = 0
                    End If
                    If Target.Offset(0, -2).Value <> "" Then
                        Target.Offset(0, -2).Value = ""
                        Target.Offset(0, -2).Interior.ColorIndex = 0
                    End If
                    Target.Interior.ColorIndex = ColourMapping("Green")
                    Target.Offset(0, 1).Value = Module1.CurrentUser()
                    Target.Offset(0, 2).Value = Format(Now(), Module1.DF)
                End If
            End If
        End Select
       ThisWorkbook.Worksheets(Module1.CMSht).Cells(2, 11).Value = False ' WorkInProgress
    End If
End Sub