Dear All, I am facing a challenge in writing a VBA Code, Can you please help. My Scenario is I have an Excel file with 2 sheet (ORIGINAL & COMPLETED) and i have a column called status in a drop down box. If i change the status to Completed, Status changed row should be moved to COMPLETED Sheet and if i change the Status again in COMPLETED sheet to Reopened, it should copy and go back to ORIGINAL sheet. I am able to move from ORIGINAL to COMPLETED. But i am unable to move from COMPLETED TO ORIGINAL based on the status change in COMPLETED Sheet.
My Code given below for reference
Private Sub Worksheet_Change(ByVal Target As Range)
Dim wsUse As Worksheet
Dim wsDc As Worksheet
Dim wsUse1 As Worksheet
Dim wsDc1 As Worksheet
Dim strdc As String
Dim strdc1 As String
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
If Target.Cells.Count > 1 Then Exit Sub
If Target.Column <> 5 Then Exit Sub ' change 2 to the correct column number
Set wsUse = ThisWorkbook.Sheets("ORIGINAL")
Set wsDc = ThisWorkbook.Sheets("COMPLETED")
With wsUse
strdc = Target.Value
If strdc = "Completed" Then
n = .Rows.Count
Target.Offset(0, 5).Value = Format(Now, "DD-MM-YYYY HH:mm")
Target.EntireRow.Copy
wsDc.Range("A" & n).End(xlUp).Offset(1, 0).PasteSpecial xlValues
wsDc.Range("A" & n).End(xlUp).EntireRow.PasteSpecial xlPasteFormats
Application.CutCopyMode = False
Target.EntireRow.Delete
End If
End With
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
My Code given below for reference
Private Sub Worksheet_Change(ByVal Target As Range)
Dim wsUse As Worksheet
Dim wsDc As Worksheet
Dim wsUse1 As Worksheet
Dim wsDc1 As Worksheet
Dim strdc As String
Dim strdc1 As String
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
If Target.Cells.Count > 1 Then Exit Sub
If Target.Column <> 5 Then Exit Sub ' change 2 to the correct column number
Set wsUse = ThisWorkbook.Sheets("ORIGINAL")
Set wsDc = ThisWorkbook.Sheets("COMPLETED")
With wsUse
strdc = Target.Value
If strdc = "Completed" Then
n = .Rows.Count
Target.Offset(0, 5).Value = Format(Now, "DD-MM-YYYY HH:mm")
Target.EntireRow.Copy
wsDc.Range("A" & n).End(xlUp).Offset(1, 0).PasteSpecial xlValues
wsDc.Range("A" & n).End(xlUp).EntireRow.PasteSpecial xlPasteFormats
Application.CutCopyMode = False
Target.EntireRow.Delete
End If
End With
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub