+ Reply to Thread
Results 1 to 9 of 9

Calculating Average ...of a dynamic data.

Hybrid View

  1. #1
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Calculating Average ...of a dynamic data.

    Hmm... I confess I have zero experience using DDE's but you would need to adopt a different event as already outlined given DDE udpates do not invoke a Change event, rather you need to use the Calculate event, however, the problem here is that technically you're open to error if the sheet recalculates on the basis of some action other than DDE update having taken place... if this is a reality we should discuss further, if not, that is to say only DDE's will be recalculating then perhaps try:

    Private Sub Worksheet_Calculate()
    Range("B1").Value = Range("B1").Value + Val(Target)
    Range("C1").Value = Range("C1").Value + 1
    End Sub
    That said, given the above to all intents & purposes becomes a Volatile Event you could just as easily dispense with VBA, enable Iteration with Max Iteration of 1 (to permit circular references) and enter formulae instead:

    B1: =B1+A1
    C1: =C1+1

  2. #2
    Registered User
    Join Date
    07-29-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Calculating Average ...of a dynamic data.

    Lol... hello again .


    Just tried your latest VBA code , its now working with the DDE update , the only problem now is B1 is showing zero (basically not summing up A1 ) but C1 is counting fine .


    I know i'm being cheeky here but i'm very interested in learning to programme VBA .... (just basic to intermediary ) any book suggestion or best way to learn ?

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Calculating Average ...of a dynamic data.

    Just tried your latest VBA code , its now working with the DDE update , the only problem now is B1 is showing zero (basically not summing up A1 ) but C1 is counting fine .
    That's because I'm a complete doofus..., should be:

    Private Sub Worksheet_Calculate()
    Range("B1").Value = Val(Range("B1").Value) + Val(Range("A1").Value)
    Range("C1").Value = Range("C1").Value + 1
    End Sub
    Re: learning VBA - self taught I'm afraid... by self I mean: Macro Recorder, Forums like this one... there are a good few books about - Walkenbach always get good reviews, PED for the more advanced programmer...

  4. #4
    Registered User
    Join Date
    07-29-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    5

    Smile Re: Calculating Average ...of a dynamic data.

    THANKS !


    It works ! thank you very very very much ....

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1