ebcopystop
New Member
- Joined
- Jan 5, 2022
- Messages
- 9
- Office Version
-
- 2016
- Platform
-
- Windows
Hello,
Brand new to VBA so bare with me.
I found a separate thread that almost solved my problem, but have a couple caveats needing attention.
I used the below code to add a row from my "TO DO" sheet to my "DONE" sheet if "Done" was entered into any cell in column K. The adds the "Done" row to the bottom of the DONE sheet and removes it from TO DO. I run into a problem, though, when I try to insert a row on "TO DO" -- I get the Type Mismatch debug error on 'If Target.Value = "Done" Then'.
Is there a way to make the DONE sheet auto sort by date (Column A) once the new row has been added?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LR As Long
If Not Intersect(Target, Range("K:K")) Is Nothing Then
If Target.Value = "Done" Then
'Copy row to "DONE" sheet and delete row
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
LR = Sheets("DONE").Range("A" & Rows.Count).End(xlUp).Row + 1
Target.EntireRow.Copy Destination:=Sheets("DONE").Range("A" & LR)
Target.EntireRow.Delete shift:=xlUp
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End If
End If
End Sub
Brand new to VBA so bare with me.
I found a separate thread that almost solved my problem, but have a couple caveats needing attention.
I used the below code to add a row from my "TO DO" sheet to my "DONE" sheet if "Done" was entered into any cell in column K. The adds the "Done" row to the bottom of the DONE sheet and removes it from TO DO. I run into a problem, though, when I try to insert a row on "TO DO" -- I get the Type Mismatch debug error on 'If Target.Value = "Done" Then'.
- I could eliminate this all together if I could figure out how to auto-sort by date (Column A) once a date is added
- I have 2 header rows that would not be included in the sort
Is there a way to make the DONE sheet auto sort by date (Column A) once the new row has been added?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LR As Long
If Not Intersect(Target, Range("K:K")) Is Nothing Then
If Target.Value = "Done" Then
'Copy row to "DONE" sheet and delete row
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
LR = Sheets("DONE").Range("A" & Rows.Count).End(xlUp).Row + 1
Target.EntireRow.Copy Destination:=Sheets("DONE").Range("A" & LR)
Target.EntireRow.Delete shift:=xlUp
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End If
End If
End Sub