我的问题如下: 当我手动更改单元格D9中的值时,下面的函数会触发“if then function”。我应该怎么做才能让它通过链接自动更改单元格D9。
换句话说,如果我将单元格D9链接到单元格A1并更改A1的值,我仍然可以使下面的函数工作吗?
Private Sub Worksheet_Change(ByVal Target As range)
If Target.Address = "$D$9" Then
If range("C12") = 0 Then
Rows("12:12").Select
Selection.RowHeight = 0
Else:
Rows("12:12").Select
Selection.RowHeight = 15
End If
End Sub
答案 0 :(得分:3)
这样的事情怎么样:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Dim rngDependents As Range
Set rngDependents = Target.Dependents
If Target.Address = "$D$9" Then
MsgBox "D9 has changed"
ElseIf Not Intersect(rngDependents, Range("$D$9")) Is Nothing Then
MsgBox "D9 has been changed indirectly"
End If
End Sub
答案 1 :(得分:0)
尝试使您的功能然后在其他单元格中使用该函数并输入到单元格d9的链接。 当您更改单元格d9处的值时,将评估您的函数。