Excel Worksheet_change 事件不再触发

Excel Worksheet_change event no longer firing

坦率地说,我不知道它什么时候停止工作,但不久就切换到使用 Office 2016。无论哪种方式,现在以前触发的 VBA 事件现在都没有触发。至少它不会停在子程序中我可以设置断点的第一个位置。

在此项目或其他打开的项目中没有使用 EnableEvents,之前触发事件的地方,进程重新格式化活动单元格和另一个,现在它什么都不做。

非常感谢任何帮助!

Public Sub Worksheet_Change(ByVal Target As Range)

Const STATUSCOL1 = "L"
Const STATUSCOL2 = "M"
Const STATUSCOL3 = "N"
Const STATUSCOL4 = "O"
Const STATUSCOL5 = "P"
Const STATUSCOL6 = "Q"
Const STATUSCOL7 = "R"
Const STATUSCOL8 = "S"
Const ACTIONCOL1 = "NOT IMPLEMENTED"


    Dim Cell As Range
    Dim ac As String
    Dim rgtCellVal As Integer

    Set Cell = Target
    ac = Split(Cell.Address, "$")(1) 'For Column Letter

    'if any changes at all mark colum J in Green
    If Target.Cells.Count = 1 Then

        'If Cell <> IIf(vOldData = vbNullString, "(Null)", vOldData) Then
        If Cell.Value <> vOldData Then
            Select Case ac
                Case ACTIONCOL1
                    Cells(Cell.Row, Range("J" & 1).Column).Interior.ColorIndex = 42 'Aqua
                Case Else
                    Cells(Cell.Row, Range("J" & 1).Column).Interior.ColorIndex = 4 'bright green
            End Select
        End If

    End If


    'Status
    '---------------------------------------------------------------------------------------------------------
    'Installed & Active
    'I&A with Bugs
    'Compromise
    'If Required
    'NotActivatedOrUsed
    'UserBlogUseOnly
    'UpdateHold
    '------------------------------------------
    'Deactivated
    'Depricated
    'Removed
    'Not Installed
    '------------------------------------------
    'Failed
    'Broken but activated
    'Broken and deactivated
    '------------------------------------------
    'Status in question
    'Ignore
    'N.A.
    'Not Actionable
    'In Progress
    'Review
    'ConsiderNew
    If ac = STATUSCOL1 Or ac = STATUSCOL2 Or ac = STATUSCOL3 Or ac = STATUSCOL4 Or ac = STATUSCOL5 Or ac = STATUSCOL6 Or ac = STATUSCOL7 Or ac = STATUSCOL8 Then

        Select Case Cell
            Case ""
                Cell.Interior.ColorIndex = xlColorIndexNone 'none

            Case "Installed & Active"
                Cell.Interior.ColorIndex = 43 'Lime

            Case "I&A with Bugs"
                Cell.Interior.ColorIndex = 36 'Light Yellow

            Case "Compromise"
                Cell.Interior.ColorIndex = 35 'Light Green

            Case "If Required"
                Cell.Interior.ColorIndex = 15 'Grey - 25%

             Case "UserBlogUseOnly"
                Cell.Interior.ColorIndex = 15 'Grey - 25%

            Case "UpdateHold"
                Cell.Interior.ColorIndex = 46 'Orange

            '------------------------------------------
            Case "NotActivatedOrUsed"
                Cell.Interior.ColorIndex = 15 'Grey - 25%

            Case "Deactivated"
                Cell.Interior.ColorIndex = 15 'Grey - 25%

            Case "Depricated"
                Cell.Interior.ColorIndex = 37 'pale blue
            Case "Removed"
                Cell.Interior.ColorIndex = 41 'Light blue
            Case "Rejected"
                Cell.Interior.ColorIndex = 41 'Light blue
            Case "Not Installed"
                Cell.Interior.ColorIndex = 37 'pale blue

            '------------------------------------------
            Case "Failed"
                Cell.Interior.ColorIndex = 3 'Red
            Case "Broken"
                Cell.Interior.ColorIndex = 3 'Red
            Case "BrokenButDeactivated"

                Cell.Interior.ColorIndex = 37 'pale blue
            '------------------------------------------

            Case "StatusInQuestion"
                Cell.Interior.ColorIndex = 44 'Gold

            Case "Ignore"
                Cell.Interior.ColorIndex = xlColorIndexNone 'none

            Case "N.A."
                Cell.Interior.ColorIndex = xlColorIndexNone 'none

            Case "Not Actionable"
                Cell.Interior.ColorIndex = xlColorIndexNone 'none

            Case "In Progress"
                Cell.Interior.ColorIndex = 15 'Grey - 25%

            Case "Review"
                Cell.Interior.ColorIndex = 33 'Sky Blue

            Case "ConsiderAlt"
                Cell.Interior.ColorIndex = 44 'Gold

            Case "------------------------------------------"
                Cell.Interior.ColorIndex = xlColorIndexNone 'none


            Case Else
                Cell.Interior.ColorIndex = 40 'Tan

                rgtCellVal = Cell.Offset(0, 1).Interior.ColorIndex
                If (Cell = "") And rgtCellVal = 15 Then
                    Cell.Interior.ColorIndex = 15
                End If
        End Select

    End If

End Sub 

我还没有 Excel 2016,但在 2007-2013 中,您可以在

下查看宏设置

文件 --> 选项 --> 信任中心 --> 信任中心设置... --> 宏设置

确保选择禁用所有带有通知的宏或更好

如果它是一个加载项,我会说检查禁用的加载项,但它看起来不像一个。

文件位于何处?如果它在网络驱动器上,当您将它复制到本地驱动器时它是否有效?
如果是这样,请检查 Trust Center Settings...

下的 Trusted Documents 选项

好的,我有答案了: 信任中心。宏设置选项卡。开发人员宏设置部分。信任对 VBA 项目对象模型的访问。勾选是!