I'm interested in how to protect a sheet in excel if the data from another sheet is copied automatically and there is a button that should work with the protected copy data? My my data copy code looks like:
Sub CopyRow1()
ActiveSheet.Unprotect Password:="pass"
Workbooks.Open Filename:="C:\Users\Desktop\workbook1.xlsm"
ThisWorkbook.Sheets("1").Range("A5:G5").Copy
Workbooks("workbook1").Sheets("Sheet1").Range("A1048567:G1048567").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False 'esp
ActiveSheet.Protect Password:="pass"
End Sub
and my code for button is:
Sub archive
Dim k, LastRow
LastRow = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).row
For k = 2 To LastRow
If Sheets("Sheet1").Cells(k, "G").Value = 0 Then
Sheets("Sheet1").Cells(k, "G").EntireRow.Cut Destination:=Sheets("Archive").Range("A" & Rows.Count).End(xlUp).Offset(1)
Sheets("Sheet1").Cells(k, "G").EntireRow.Delete
End If
Next k
End Sub