Results 1 to 28 of 28

UDF to capture change in cell values

Threaded View

  1. #10
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: UDF to capture change in cell values

    What you're saying is that you only want to trigger a UDF() if a value actually changes to a different value, not if it changes to the same value.

    I've never heard of a way to tell Excel to not trigger a UDF() if the new value is the same as the old value. As far as I know you have to store the old value and compare the new value to the old value.

    The UDF() could be made faster by having it trigger just once for the entire 1000 rows and keep the old values in memory instead of on a worksheet. So at least it doesn't take the time to save the values to disk.

    Sub Trigger(ByVal r as Range)
        Static aOldValues
        Dim aNewValues
        Dim lRow as Long, lCol as Long
    
        If uBound(aOldValues,1) <= 0 Then
            aOldValues = r.Value
        Else
            aNewValues = r.Value
            For lRow = 1 to r.Rows.Count
                For lCol = 1 to r.Columns.Count
                    If aNewValues(lRow, lCol) <> aOldValues(lRow, lCol) Then
                        MsgBox "Success"
                        aOldValues = aNewValues
                        Exit Sub
                    End If
                Next lCol
            Nes lRow
        End If
    End Sub
    Last edited by foxguy; 11-18-2011 at 11:25 PM.

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