Hello! Excel Forum is the best place for help when I get stuck. Thank you for any replies!
I was able to get help creating some code to copy a row to another sheet and then deleting that row. I didn't want the data to be compromised in anyway so I am protecting the sheet. I added in code to un-protect (as the sheet will be protected) and then some actions and then protect the sheet again. The problem I am running into is the second sheet I am copying to is protected and for some reason I can't get the code to un-protect the second sheet. Help!
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim wb As Workbook
Dim wsComp As Worksheet
Dim wsActive As Worksheet
Dim lastrow As Long
Dim i As Long
Dim KeyCells As Range
Set wb = ThisWorkbook
Set wsComp = wb.Worksheets("Completed")
Set wsActive = wb.Worksheets("Active")
Set KeyCells = wsActive.Range("E:F")
If Not Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then
lastrow = wsComp.Cells(Rows.Count, "A").End(xlUp).Row
ActiveSheet.Unprotect Password:="Password"
If wsActive.Cells(Target.Row, 5).Value <> vbNullString And wsActive.Cells(Target.Row, 6).Value <> vbNullString Then
wsComp.Unprotect Password:="Password"
wsActive.Rows(Target.Row).Copy Destination:=wsComp.Range("A" & lastrow + 1)
wsComp.Protect Password:="Password"
wsActive.Rows(Target.Row).Delete
ActiveSheet.Protect Password:="Password"
End If
End If
End Sub
Bookmarks