tags:

views:

43

answers:

2

Hi,

My problem is the following: The function below triggers an "if then function" when i manually change the value in cell D9. What should I do to get it to work with an automatic value change of cell D9 trough a link.

In other words if i where to link cell D9 to cell A1 and change the value of A1 can i still make the function below work?

Thanks in advance

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

+2  A: 

How about something like this:

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
Thanks a lot I got it to work!!!!!
Jesse
A: 

try to make your function then in other cell use the function with input the link to the cell d9. When you change the value at cell d9 your funtion will be valuated.

Ibhar