+ Reply to Thread
Results 1 to 2 of 2

Trigger code by Drop Down

Hybrid View

  1. #1
    Registered User
    Join Date
    09-06-2013
    Location
    Champaign, Illinois
    MS-Off Ver
    Excel 2007
    Posts
    7

    Trigger code by Drop Down

    Hey everyone,

    I have a VBA Code which moves the entire row to the second worksheet if it contains the word "Closed" in column A. I was wondering if someone could help me make the code refer to a drop down list which I will create. For some reason, when I create the drop down list for Column A, the code no longer works. Below is the code.

    Private Sub Worksheet_Change(ByVal Target As Range)
     If Intersect(Target, Range("A2:A9")) Is Nothing Then Exit Sub
     If Target.Count > 1 Then Exit Sub
     If Target = "" Then Exit Sub
     Dim NR As Long
     With Application
     .EnableEvents = False
     .ScreenUpdating = False
     Select Case Target.Value
     Case "Closed"
     Range("A" & Target.Row & ":M" & Target.Row).Copy Worksheets("Completed").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
     Target.EntireRow.Delete Shift:=xlUp
     End Select
     .EnableEvents = True
     .ScreenUpdating = True
     End With
     End Sub
    Any help would be greatly appreciated!

    Thanks!

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2411
    Posts
    26,754

    Re: Trigger code by Drop Down

    Is your dropdown list a data validation list? As far as the code is concerned, a cell where "Closed" is selected from a data validation list should behave exactly the same as if the user typed "Closed" into a plain vanilla cell. Can you attach the version of your file that doesn't work? Even if you have to delete all the data except one row of fake data, that's fine, as long as the data validation is still there and you give some idea of what the data looks like.

    Also note that when it comes to code, indentation is a virtue.

    (Is that drive-thru burrito place still in Champaign, the one with "Burritos Bigger Than Your Head"?)
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Allow code to run once then not until it's trigger value appears again
    By ozhunter in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-18-2013, 08:04 AM
  2. Drop down list to trigger a macro
    By HraHuuh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-11-2012, 07:32 AM
  3. How to trigger code execution?
    By alwaysgo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2008, 09:11 AM
  4. Trigger Event Code
    By Shawn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-14-2005, 10:05 AM
  5. Code to trigger drop down-select event
    By Excel User in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-10-2005, 04:06 PM

Tags for this Thread

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