2016-03-03 94 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