Results 1 to 16 of 16

Deleting specific cells when a condition is no longer met

Threaded View

  1. #1
    Registered User
    Join Date
    01-04-2018
    Location
    Reading, England
    MS-Off Ver
    Excel 2016
    Posts
    19

    Deleting specific cells when a condition is no longer met

    Hello,

    I have this coding below, which works really well, by automatically copying and pasting specific cells from worksheet1 onto worksheet2 when specific words are chosen in worksheet1 cell L from a drop down menu. The problem I have is that once the cells are pasted onto worksheet2, they won’t be deleted if the choice on dropdown menu in worksheet1 cell L changes. Any way to solve this? I thought of adding a subroutine to check for duplicates and delete one as no 2 records will be the same but I have no clue how to add this. Hopefully someone will be able to help me.
    Thanks

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim s As String, r, rng As Range, sh As Worksheet
    Set sh = Sheets("Decision")
    s = "Exit from this plan and entering another"
    
    If Target.Count > 1 Then Exit Sub
    
    If Target.Column = 12 Then
    If Target = s Then
    r = Target.Row
    Set rng = Range("A" & r & ":H" & r)
    With sh
    rng.Copy .Cells(.Rows.Count, "A").End(xlUp).Offset(1)
    End With
    End If
    End If
    
    End Sub
    Last edited by AliGW; 01-06-2018 at 02:21 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Deleting Specific Data in Specific Cells
    By emily8134 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-18-2013, 10:51 AM
  2. VBA for deleting cells containing specific text
    By andrewzzz in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-25-2013, 08:55 AM
  3. Deleting worksheets if they no longer appear in a list
    By iamrickdeans in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-22-2013, 04:39 AM
  4. Deleting cells with a condition
    By este994 in forum Excel General
    Replies: 0
    Last Post: 07-29-2011, 06:48 AM
  5. Deleting cells from a specific row, specified by a combo box
    By Smurlos in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-17-2011, 07:35 AM
  6. Clearing cells and deleting rows based on condition
    By vijay2482 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-14-2010, 10:08 AM
  7. Deleting Specific Range of Cells via Condition
    By Excel Newbie05 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-06-2008, 04:44 AM
  8. [SOLVED] Deleting specific cells in a selected row
    By Jeff Wright in forum Excel General
    Replies: 5
    Last Post: 04-17-2005, 01:06 PM

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