我有一张表,我想让用户选择计算类型。计算类型是通过数据验证中的列表选择来完成的。选择后,我希望它触发一个事件,然后为该类型的选择加载正确的单元格。如何在数据验证下拉菜单中检测数据更改事件,或者我是否需要为此使用活动 x 控件?
工作表更改事件的代码未激活:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.count > 1 Then Exit Sub
Application.EnableEvents = False
On Error GoTo Errortrap
'~~> Change it to the relevant string with which you want to compare
StringToCheck = "+"
If Not Intersect(Target, Range("D47")) Is Nothing Then
'~~> Check for the cell value
If Target.Value = StringToCheck Then
'setup row to capture addition fields
Cells(33, 4).Value = "Input File 1"
Cells(33, 4).Value = "Worksheet 1"
Cells(33, 4).Value = "Cell 1"
Cells(33, 4).Value = "Input File 2"
Cells(33, 4).Value = "Worksheet 2"
Cells(33, 4).Value = "Cell 2"
End If
End If
LetsContinue:
Application.EnableEvents = True
Exit Sub
Errortrap:
MsgBox Err.Description
Resume LetsContinue
End Sub