Results 1 to 10 of 10

Capture Cell Value Before Change Event

Threaded View

  1. #1
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Capture Cell Value Before Change Event

    I am trying to capture the value of a cell before a change even. The attached Macro will report the value before the change but does not store it so that I can use it in another module. What I am trying to do is capture the value before the change and then look that value up in another worksheet (in the same workbook) so I can make the same change in the second workbook.

    The values will always be in Column B and will always be string characters.

    The code I am using for the change event is as follows:

    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim OldValue As String
        If Flag Then Exit Sub
        If Intersect(Target, Range("B7:B132")) Is Nothing Then Exit Sub
        With Application
            On Error GoTo ErrHandler
            .EnableEvents = False
            .Undo
            OldValue = Target.Cells(1).Value
            .Undo
            .EnableEvents = True
        End With
        MsgBox "Value was " & OldValue
    ErrHandler:
        Application.EnableEvents = True  
        If Err.Number <> 0 Then
            MsgBox "Error: " & Err.Number & vbNewLine & Err.Description
        End If
    End Sub
    Can you give me some direction on how to capture the OldValue so as to use it as a variable in another module?

    Thanks...John
    Last edited by jaslake; 03-04-2009 at 01:00 PM.

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