ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   MACRO: Selecting "Cancel" from a drop down to copy and paste entirerow to another sheet (https://www.excelbanter.com/excel-discussion-misc-queries/237432-macro-selecting-cancel-drop-down-copy-paste-entirerow-another-sheet.html)

Nicole Hannington

MACRO: Selecting "Cancel" from a drop down to copy and paste entirerow to another sheet
 
I am trying to create a macro for a project management sheet in
excel. I have a column that has a drop down validation; when "Cancel"
is selected, I would like the entire row to be moved to "Sheet2" in
the workbook. I want this to work for all of the projects (each
listed on a different row). I do not have that much experience with
macros, so detailed instructions will be grately appreciated :)

Jim Thomlinson

MACRO: Selecting "Cancel" from a drop down to copy and paste entir
 
Here is how I would go about it... You need a way to determine if Cancel was
choosen in the specific cells where doing so requires a copy operation. To
that end I would create locally defined named ranges on the cells (on each
sheet) where your validation exists (I used the word This as my names
ranges). At that point can you can use sheet change code in ThisWorkbook do
determine that the change requires a copy with code similar to this...

(Right click the XL icon in the upper left cornter of the XL window and
select View Code. Paste the Following)

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Not Intersect(Sh.Range("This"), Target) Is Nothing And _
Target.Value = "Cancel" Then
Target.EntireColumn.Copy Destination:=Sheets("Sheet2").Range("A1")
End If
End Sub

There is more to the code than this but it is a start...
--
HTH...

Jim Thomlinson


"Nicole Hannington" wrote:

I am trying to create a macro for a project management sheet in
excel. I have a column that has a drop down validation; when "Cancel"
is selected, I would like the entire row to be moved to "Sheet2" in
the workbook. I want this to work for all of the projects (each
listed on a different row). I do not have that much experience with
macros, so detailed instructions will be grately appreciated :)



All times are GMT +1. The time now is 12:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com