+ Reply to Thread
Results 1 to 3 of 3

comparing current value with previous value in cell of excel sheet linked to rtd

Hybrid View

  1. #1
    Registered User
    Join Date
    01-02-2012
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    2

    comparing current value with previous value in cell of excel sheet linked to rtd

    i have excel sheet linked to real time data(stock ticks), i want to compare value of current tick to that of previous tick in given cell (is new value greater than or lesser than previous)e.g. stock price ticks- i want to compare price in current tick to that of previous value so that i can know was it increment or decrease,i can do this by transferring data to .csv file and then processing it but i like to know is there any method so that i can do this in excel itself using excel formulas or vba etc.?i have excel 2010 version
    regards
    Last edited by sank; 01-02-2012 at 08:34 AM.

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

    Re: comparing current value with previous value in cell of excel sheet linked to rtd

    You could use the Calculate event and a Static variable

    Private Sub Worksheet_Calculate()
        Static vPrior As Variant
        With Range("A1")
            If .Value <> vPrior Then
                MsgBox "New: " & .Value & vbLf & vbLf & "Old: " & vPrior, vbInformation, "Change"
                vPrior = .Value
            End If
        End With
    End Sub
    How practical the above approach will be for you will depend largely on frequency of update etc... use of MsgBox purely for sake of demo.

    Also, if you're comparing a lot of values simultaneously I would suggest you cache the prior values rather than a multitude of Static variables.
    (note: Static variables only persist within session)

  3. #3
    Registered User
    Join Date
    01-02-2012
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: comparing current value with previous value in cell of excel sheet linked to rtd

    thanks donkeyote, and yes, i am comparing 50 values at a time,so i guess i have to cache data, is there way to cache it temporarily within excel, i mean save just previous value for comparison,and delete it on next input ,i searched but can't find anything about it
    Last edited by sank; 01-02-2012 at 10:13 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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