我不知道這是什麼時候停止工作,坦率地說,但不是很長時間切換到使用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
我不想成爲「那些」傢伙之一,但爲什麼不使用條件格式?是否有任何VB代碼運行?宏或工作簿是否被禁用? – Profex
嗯,可能有條件形成的規則數量已經改變了,但之前我認爲有三個限制。如果現在有更多的數字可以實現這一點,那麼它可能是一個更容易的選擇。然而,也可能是簡單的事情需要改變方法。因此,這個問題。另外我不想爲了它而創建24條規則,如果它是一個簡單的修復方法,用於解決某些問題。 –
在您的其他問題@Profex我沒有意識到這一點,但只有一個其他事件代碼「Worksheet_SelectionChange」和ineed這也不是射擊。我將如何禁用VBA或者你是否說我需要在Excel 2016中啓用它?即默認禁用? –