Consulting

Results 1 to 2 of 2

Thread: VBA Event Change Using Dependents

  1. #1
    VBAX Newbie
    Joined
    Jan 2015
    Posts
    5
    Location

    VBA Event Change Using Dependents

    Hello,

    To give a bit of background, I have an excel workbook where multiple calculations are performed on different sheets. In order to simplify the calculations I have created a summary sheet where I intend to change the input values and observe the output values which are linked to the relevant sheets. There are over 200 output values so I would like the vba code to give me a message box stating which values have changed.

    In order to do this I plan to check for an change event using dependents. For instance if I change an input, using dependents I should be able to find which outputs have changed.

    My code can be seen below.

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Dependents As Range
    Set Dependents = Range(Target.Dependents.Count)
    If InStr(Dependents, Range("F6:F233")) Is Nothing Then
    MsgBox "Change"
    End If
    End Sub

    I have two questions. Firstly, is this the right way to go about solving this problem? Secondly, is it possible to use dependents over multiple sheets?
    I am fairly new to vba so any help would be appreciated.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It is possible to track dependencies over multiple sheets, but it is far from easy. I did something on a dependency tree a few years ago, I wouldn't advise anyone to try it.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •