Results 1 to 19 of 19

Thread: Help with code to copy cell value before change event

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,970
    try:
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rngToProcess As Range, sNewValue
    Set rngToProcess = Intersect(Target, Range("C5:C14"))
    If Not rngToProcess Is Nothing Then
      Application.EnableEvents = False
      sNewValue = Target.Value
      Application.Undo
      Target.Offset(, 1).Value = Target.Value
      Target.Value = sNewValue
      Application.EnableEvents = True
    End If
    End Sub
    If you have problems with multiple cells being changed at once (say by copying data from another range, or from selecting a range and holding down the Ctrl key while Entering a value) come back. (In my quick testing I had no problems with multiple cell changes at once.)
    Last edited by p45cal; 12-03-2023 at 08:12 AM.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Posting Permissions

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