Consulting

Results 1 to 2 of 2

Thread: Retrieving old Target Value

  1. #1
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location

    Retrieving old Target Value

    Is is possible to display a target's old value after you have changed the Target value???

    Here is an example of displaying the new value:

    Option Explicit 
    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    Dim R       As Range
    Dim RVal    As Long
    For Each R In Target
        RVal = R.Value
        MsgBox "New value is: " & RVal
    Next
    End Sub
    How could I make this so that it would display the old value???




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  2. #2
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Nevermind, I got it.

    Private OldValue As Variant 
     
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    OldValue = Target.Cells(1, 1).Value
    End Sub
     
    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    MsgBox "Old value was: " & OldValue
    End Sub
    Thanks to Jindon at MrExcel.com
    Thanks for reading.




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

Posting Permissions

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