Drop Down Selections

jmk15315

Board Regular
Joined
Nov 7, 2021
Messages
73
Office Version
  1. 2013
  2. 2010
Platform
  1. Windows
I have a simple spreadsheet that has multiple columns of information with each row as a new "task". One of the columns has a dropdown list for the status of the task (N/A, Not Started, In Progress, Completed & Filed).

Is there a way to have the sheet automatically copy that specific row of sheet1 to the last row of sheet2, then delete the row from sheet1 that was just copied/pasted? I am trying to avoid adding checkboxes or buttons. Hoping there is a quick macro that can execute based on the selection of "Filed" in that field.

Any thoughts?
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Do you want to copy the row automatically when you make a selection in the drop down list?
 
Upvote 0
Correct, Once "Filed" is selected, I would like it to copy/paste/delete
 
Upvote 0
Copy and paste this macro into the worksheet code module. Do the following: right click the tab name for your Sheet1 and click 'View Code'. Paste the macro into the empty code window that opens up. Change the number "1" (in red) to the column number where you have your drop down list. Close the code window to return to your sheet. Select "Filed" in any row.

Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Target.Column <> 1 Then Exit Sub
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    If Target = "Filed" Then
        With Target.EntireRow
            .Copy Sheets("Sheet2").Cells(Sheets("Sheet2").Rows.Count, "A").End(xlUp).Offset(1)
            .Delete
        End With
    End If
    Application.EnableEvents = True
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
The status "FILED" is in column "K" (11) so I changed the second line of code
From"If Target.Column <> 1 Then Exit Sub"
To "If Target.Column <> 11 Then Exit Sub"

I get no action when changing the value in the column to "Filed". I thought perhaps it might be case sensitive, so I changed
From If Target = "Filed" Then
to If Target = "FILED" Then
but that did not return any different results.

I have ensured that the two sheets being used for the transfer of data are configured the same (cell width) and still no change.

Thoughts?
 

Attachments

  • 1718017024933.png
    1718017024933.png
    8.5 KB · Views: 5
  • 1718017139476.png
    1718017139476.png
    60.3 KB · Views: 5
Upvote 0
I tested the macro on some dummy data and it worked properly. Did you place the macro in the worksheet code module as I described in Post #4? Also, if you tried the macro and it produced an error at any time, try running this short macro first:
VBA Code:
Sub test()
    Application.EnableEvents = True
End Sub
and then try the Worksheet_Change macro again. If it still doesn't work, it would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of your sheet. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
 
Upvote 0
I did, yes. In reading the code to try and understand (learn) what is taking place, I see the following:
VBA Code:
    If Target = "Filed" Then
        With Target.EntireRow
            .Copy Sheets("Sheet2").Cells(Sheets("Sheet2").Rows.Count, "A").End(xlUp).Offset(1)
            .Delete
        End With
    End If
The intent is to "Copy" entire row from Sheet1 ("CDRH Tracking Report") that has a value of "Filed" in Column "K" and paste to Sheet2 ("Reports Filed") to the last row. Then delete the entire row from Sheet1 ("CDRH Tracking Report")

I see the "Copy" command, and I can change the name of the sheet but I don't see to where it is pasting this data. It is also not deleting the row from the "Source" sheet.

I apologize for being dense, I am trying to learn but I am definitely a beginner for sure. What am I missing?
 
Upvote 0
This is the macro with explanatory comments:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Target.Column <> 11 Then Exit Sub
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    If Target = "Filed" Then
        With Target.EntireRow 'references the entire row
            .Copy Sheets("CDRH Tracking Report").Cells(Sheets("CDRH Tracking Report").Rows.Count, "A").End(xlUp).Offset(1) 'copies the referenced row to first blank row in "CDRH Tracking Report"
            .Delete 'deletes the referenced row
        End With
    End If
    Application.EnableEvents = True
    Application.ScreenUpdating = True
End Sub
As I mentioned, the macro worked properly for me in a dummy file. Please follow the instructions in Post #6 to attach screenshots or upload your file.
 
Upvote 1

Forum statistics

Threads
1,223,868
Messages
6,175,084
Members
452,611
Latest member
bls2024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top