Results 1 to 8 of 8

Thread: 2 Vba Routines - stop working

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    VBAX Regular
    Joined
    May 2018
    Posts
    9
    Location
    I made the code changes. J9:J12 is defined as accounting. The first time I ran it, the bottom grid line of E12 disappeared. I submitted reset_events after that happened. I reran and the results were the same. E9 - E12 did not copy to J9 - J12. Below is my code:

    UPDATE - PLEASE READ BELOW THEN LOOK AT THE RED BELOW THIS

    Private Sub Worksheet_Change(ByVal Target As Range)
    ' Check to see if cell G3 updated
    If Target.Address <> "$G$3" Then Exit Sub


    Application.EnableEvents = False


    If UCase(Target) = "YES" Then
    Range("J9:J12").Copy Range("E9")
    ElseIf UCase(Target) = "NO" Then
    Range("E9:E12").ClearContents
    End If


    Application.EnableEvents = True


    End Sub

    UPDATE
    The original code you sent to me (below) will work if I toggle between YES and NO after doing the CLEAR

    Private Sub Worksheet_Change(ByVal Target As Range)
    ' Check to see if cell G3 updated
    If Target.Address <> "$G$3" Then Exit Sub


    Application.EnableEvents = False


    If Target.Value = "YES" Then
    Range("E9:E12").Value = Range("J3:J6").Value
    ElseIf Target.Value = "NO" Then
    Range("E9:E12").ClearContents
    End If


    Application.EnableEvents = True


    End Sub
    Last edited by jgold20; 05-07-2018 at 02:29 AM. Reason: Update to problem

Posting Permissions

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