2016-03-03 95 views
0

我不知道这是什么时候停止工作,坦率地说,但不是很长时间切换到使用Office 2016.无论哪种方式,以前发射的VBA事件现在不是这样做。至少它不会停留在我可以设置断点的子集中的第一个位置。Excel Worksheet_change事件不再发射

在此项目或其他打开的项目中没有使用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 
+0

我不想成为“那些”家伙之一,但为什么不使用条件格式?是否有任何VB代码运行?宏或工作簿是否被禁用? – Profex

+0

嗯,可能有条件形成的规则数量已经改变了,但之前我认为有三个限制。如果现在有更多的数字可以实现这一点,那么它可能是一个更容易的选择。然而,也可能是简单的事情需要改变方法。因此,这个问题。另外我不想为了它而创建24条规则,如果它是一个简单的修复方法,用于解决某些问题。 –

+0

在您的其他问题@Profex我没有意识到这一点,但只有一个其他事件代码“Worksheet_SelectionChange”和ineed这也不是射击。我将如何禁用VBA或者你是否说我需要在Excel 2016中启用它?即默认禁用? –

回答

0

我没有Excel 2016还,但2007 - 2013年你可以在

文件-->选项-->信任中心-->信任中心设置检查微距设置.. 。-->宏设置

确保禁用所有通知的宏或更高版本被选中

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

该文件位于何处?如果它位于网络驱动器上,当它复制到本地驱动器时它是否工作?
如果是的话,则检查受信任的文档的信任中心设置下选项...

+0

VBA与宏不一样。没有涉及加载项。没有外部文件,除非你是指Access文件本身。 –

+0

在Excel中,宏= VBA。我有没有想到你对Access有什么看法? – Profex

+0

确实很抱歉错别字我应该说Excel!我必须承认来自一个主要的访问背景(因此滑),我没有说明,在excel中它们是同一个! –

0

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

+0

该设置允许您通过代码更改VBA代码。即我可以编写一种病毒,将VBA代码添加到您拥有的任何Excel文档中,或者删除您的所有VBA代码。我很高兴你找到了有效的设置,但要小心这个设置。 – Profex