[英]2 private sub worksheet_change
我有以下代碼:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim C As Range, D As Range, v
Set C = Range("C1:C20")
Set D = Range("D1:D20")
v = Target.Value
If Intersect(Union(C, D), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
If Intersect(Target, D) Is Nothing Then
Target.Offset(0, 1).Value = 12 * v
Else
Target.Offset(0, -1).Value = v / 12
End If
Application.EnableEvents = True
Dim H As Range, I As Range, v2
Set H = Range("H8:H11")
Set I = Range("I8:I11")
v2 = Target.Value
If Intersect(Union(H, I), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
If Intersect(Target, I) Is Nothing Then
Target.Offset(0, 1).Value = 12 * v2
Else
Target.Offset(0, -1).Value = v2 / 12
End If
Application.EnableEvents = True
'Sheets("Költségvetés").AutoFilter.ApplyFilter
' first remove filter
ActiveSheet.Range("$F$54:$$67").AutoFilter Field:=2
' then apply it again
ActiveSheet.Range("$F$54:$$67").AutoFilter Field:=2, Criteria1:="<>0"
End Sub
我想要一個餅圖,每當輸入新值時都會更新,並且不顯示 0 值項目的數據標簽。
謝謝!
If Intersect(Union(C, D), Target) Is Nothing Then Exit Sub
正在阻止第二部分運行。 改成
Set all your ranges etc
If Not Intersect(Union(C, D), Target) Is Nothing Then
'... first section
ElseIf Not Intersect(Union(H, I), Target) Is Nothing Then
'... second section
End If
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.