VBA to shift task when done

OGCV1

New Member
Joined
Nov 12, 2017
Messages
36
Hey Guys

So am new to VBA and am having a problem with the below:

Code:
Sub Worksheet_Change(ByVal Target As Range)    On Error Resume Next
    Application.EnableEvents = False
    If Target.Column = 2 And Target.Value = "Done" Then
        LRowCompleted = Sheets("Jobs").Cells(Rows.Count, "L").End(xlUp).Row
        Range("A" & Target.Row).Copy Sheets("Jobs").Range("L" & LRowCompleted + 1)
        Range("M" & LRowCompleted + 1) = Format(Date, "mm/dd/yy")
        Range("A" & Target.Row & ":B" & Target.Row).Delete xlShiftUp
    End If
    If Target.Column = 4 And Target.Value = "Done" Then
        LRowCompleted = Sheets("Jobs").Cells(Rows.Count, "N").End(xlUp).Row
        Range("C" & Target.Row).Copy Sheets("Jobs").Range("N" & LRowCompleted + 1)
        Range("O" & LRowCompleted + 1) = Format(Date, "mm/dd/yy")
        Range("C" & Target.Row & ":D" & Target.Row).Delete xlShiftUp
    End If
     If Target.Column = 6 And Target.Value = "Done" Then
        LRowCompleted = Sheets("Jobs").Cells(Rows.Count, "P").End(xlUp).Row
        Range("E" & Target.Row).Copy Sheets("Jobs").Range("P" & LRowCompleted + 1)
        Range("Q" & LRowCompleted + 1) = Format(Date, "mm/dd/yy")
        Range("E" & Target.Row & ":F" & Target.Row).Delete xlShiftUp
    End If
     If Target.Column = 8 And Target.Value = "Done" Then
        LRowCompleted = Sheets("Jobs").Cells(Rows.Count, "R").End(xlUp).Row
        Range("G" & Target.Row).Copy Sheets("Jobs").Range("R" & LRowCompleted + 1)
        Range("S" & LRowCompleted + 1) = Format(Date, "mm/dd/yy")
        Range("G" & Target.Row & ":H" & Target.Row).Delete xlShiftUp
    End If
      If Target.Column = 10 And Target.Value = "Done" Then
        LRowCompleted = Sheets("Jobs").Cells(Rows.Count, "T").End(xlUp).Row
        Range("I" & Target.Row).Copy Sheets("Jobs").Range("T" & LRowCompleted + 1)
        Range("U" & LRowCompleted + 1) = Format(Date, "mm/dd/yy")
        Range("I" & Target.Row & ":J" & Target.Row).Delete xlShiftUp
    End If
    Application.EnableEvents = True

I have 5 projects on the go and each project has 2 columns (task and status). When a task for that project is complete I should be able to type Done in the status column and it will move that task to a completed list (which is the same layout but has the that is was completed in the status column)
This all seems to go swimmingly except that the date appears in all the status columns of the completed list and not just the project for which task it was.

Would appreciate any advice

Thanks in advance, OGCV
 

Some videos you may like

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,278
You didn't qualify the Jobs worksheet for the dates

Code:
[B]Sheets("Jobs").[/B]Range("M" & LRowCompleted + 1) = Format(Date, "mm/dd/yy")
 

OGCV1

New Member
Joined
Nov 12, 2017
Messages
36
AlphaFrog,

Thanks for the reply.
Tried this but still coming up with the same problem.

OGCV
 

Watch MrExcel Video

Forum statistics

Threads
1,109,341
Messages
5,528,146
Members
409,802
Latest member
joeino

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top