尝试进行以下更改:
Option Explicit
Public Sub SetTabelle3Validation()
Const V_LIST = "Relevant,For Discussion,Not Relevant"
Dim ws As Worksheet: Set ws = Tabelle3
Dim lr As Long: lr = ws.Range("AV" & ws.Rows.Count).End(xlUp).Row
Dim app As Application: Set app = Application
Dim fc As Range
If lr > 9 Then
Set fc = ws.Range(ws.Cells(9, "AV"), ws.Cells(lr, "AV"))
fc.Validation.Delete
fc.AutoFilter Field:=1, Criteria1:="<>"
If fc.SpecialCells(xlCellTypeVisible).Cells.Count > 1 Then
app.EnableEvents = False
app.ScreenUpdating = False
With fc.SpecialCells(xlCellTypeVisible).Validation
.Add Type:=xlValidateList, _
AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, _
Formula1:=Join(Split(V_LIST, ","), app.International(xlListSeparator))
End With
app.ScreenUpdating = True
app.EnableEvents = True
End If
fc.AutoFilter
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lr As Long: lr = Me.Rows.Count
Dim lrT3 As Long: lrT3 = Me.Range("A" & lr).End(xlUp).Offset(8).Row
Dim app As Application: Set app = Application
Dim inAV As Boolean
inAV = Not Intersect(Target, Me.Range("AV9:AV" & lrT3)) Is Nothing
With Target
If .Cells.CountLarge > 1 Or Not inAV Or Len(.Value) = 0 Then Exit Sub
app.EnableEvents = False
If .Value = "Relevant" Or .Value = "For Discussion" Then
Me.Cells(.Row, "A").Resize(, 57).Copy
With Tabelle14.Range("A" & lr).End(xlUp).Offset(1)
.PasteSpecial xlPasteValues
.PasteSpecial xlPasteFormats
.PasteSpecial xlPasteColumnWidths
End With
Tabelle14.UsedRange.RemoveDuplicates Columns:=Array(1)
End If
Me.Cells(.Row, "A").Resize(, 2).Copy
With Tabelle10
.Range("A" & lr).End(xlUp).Offset(1).PasteSpecial xlPasteValues
.UsedRange.RemoveDuplicates Columns:=Array(1)
End With
app.CutCopyMode = False
app.EnableEvents = True
End With
End Sub
在
SetTabelle3Validation()
-
更换
For
循环
AutoFilter
对于速度
-
转弯
Application.EnableEvents
关闭以停止触发
Worksheet_Change()
(然后再打开)
在
工作表更改()
-
如果粘贴多个值、目标不在列AV中或为空,则退出Sub。
-
否则(
Target
在列中
AV
,不为空)
-
转弯
应用程序.enableEvents
下车
-
如果
靶标
值是
"Relevant"
或
"For Discussion"
,更新
Tabelle14
-
否则(
靶标
值是
"Not Relevant"
)更新
Tabelle10
-
转弯
应用程序.enableEvents
论
假设
-
所有对象从开始
Tabelle
是吗?
代码名称
其他页
-
工作表更改()
属于
Tabelle3