I'm having some issues here. I have two Private Sub Worksheet_Change that I need in one worksheet. I can't figure out how to make it work with both private subs. Below is my coding. Any ideas would be so helpful!!
Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) ' stanleydgromjr, 09/05/2011 ' Version 3, after copying the Target.Row, delete the Target.Row ' http://www.excelforum.com/excel-programming/790860-move-entire-row-to-another-worksheet-based-on-cell-value.html If Intersect(Target, Range("D:D")) Is Nothing Then Exit Sub If Target.Count > 1 Then Exit Sub If Target = "" Then Exit Sub Dim P As Long, NR As Long With Application .EnableEvents = False .ScreenUpdating = False Select Case Target.Value Case "Booked" P = Application.Match("Potential", Worksheets("Booked").Columns(4), 0) NR = Worksheets("Booked").Range("D" & P).End(xlUp).Offset(1).Row Range("A" & Target.Row & ":J" & Target.Row).Copy Worksheets("Booked").Range("A" & NR) Rows(Target.Row).Delete Case "DNMQ" P = Application.Match("Potential", Worksheets("DNMQ").Columns(4), 0) NR = Worksheets("DNMQ").Range("D" & P).End(xlUp).Offset(1).Row Range("A" & Target.Row & ":J" & Target.Row).Copy Worksheets("DNMQ").Range("A" & NR) Rows(Target.Row).Delete End Select .EnableEvents = True .ScreenUpdating = True End With End Sub Private Sub Worksheet_Change1(ByVal Target As Range) SetDateRow Target, "G" 'or 'SetDateCol Target, 5 End Sub Sub SetDateRow(Target As Range, Col As String) If Target.Cells.Count > 1 Then Exit Sub Application.EnableEvents = False Cells(Target.Row, Col) = Int(Now()) Application.EnableEvents = True End Sub Sub SetDateCol(Target As Range, Rw As Long) If Target.Cells.Count > 1 Then Exit Sub Application.EnableEvents = False Cells(Rw, Target.Column) = Now() Application.EnableEvents = True End Sub
Try this:
Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim P As Long Dim NR As Long If Target.Cells.Count > 1 Then Exit Sub On Error GoTo Oops Application.EnableEvents = False Cells(Target.Row, "G") = Date If Target.Column = 4 Then Select Case Target.Value Case "Booked" P = WorksheetFunction.Match("Potential", Worksheets("Booked").Columns(4), 0) NR = Worksheets("Booked").Cells(P, "D").End(xlUp).Offset(1).Row With Target.EntireRow .Range("A1:J1").Copy Worksheets("Booked").Cells(NR, "A") .Delete End With Case "DNMQ" P = WorksheetFunction.Match("Potential", Worksheets("DNMQ").Columns(4), 0) NR = Worksheets("DNMQ").Cells(P, "D").End(xlUp).Offset(1).Row With Target.EntireRow .Range("A1:J1").Copy Worksheets("DNMQ").Cells(NR, "A") .Delete End With End Select Oops: Application.EnableEvents = True End If End Sub
Microsoft MVP - Excel
Entia non sunt multiplicanda sine necessitate
That code didn't work for me. Let me tell you what it needs to do because the current code can be re-written probably. I'm not sure if its the most effective way or if its compatible with eachother.
I'm going to attach the document and then explain what I'm trying to have happen.
1) worksheet named current: when I change the status in status column to Booked - the entire row will be deleted and moved to the Booked worksheet.
2) worksheet named current: when I change the status in the status column to DNMQ - the entire row will be deleted and moved to the DNMQ worksheet.
3)worksheet named current: when I change the status in the status column to Application, I want todays date to appear in the App Date column (G). I don't want this date to change each time its updated or saved though. A static date if you will. Also, if I change from Approved to closing I dont want the date to change in the column G. Once its there I don't need it to change for tracking purposes.
4) Finally, when there is a change in columns A-F I want another static date to appear in column J. This date wont change until their is any change in columns A-F.
Any help or ideas would be so appreciated.
Hello bdf0827,
There is and always will be one and only one Worksheet Change event per worksheet. All the code therefore must be combined into the one event module.
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
That's not very helpful. Did it do nothing? Something, but not what you wanted? In what way?That code didn't work for me.
Are you looking for someone to code to your specifications (aka, a consultant), or someone to help you help yourself?
Microsoft MVP - Excel
Entia non sunt multiplicanda sine necessitate
Find another forum then
You haven't even used the suggested code
Last edited by royUK; 11-14-2011 at 02:15 AM.
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
It's not used in your attachment so how can we tell if you have used it correctly?
Any way uou have the option to go
Hope that helps.
RoyUK
--------
If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need
For Excel Tips & Solutions, free examples and tutorials why not check out my downloads
New members please read & follow the Forum Rules
Remember to mark your questions Solved and rate the answer(s)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks