Hi,
Im getting an error below when running a macro below. It must be related somehow on unprotecting the master sheet as the code worked perfectly without that.
Any ideas how to fix this?
Thanks in advance!
Im getting an error below when running a macro below. It must be related somehow on unprotecting the master sheet as the code worked perfectly without that.
Any ideas how to fix this?
Thanks in advance!
VBA Code:
Sub CopyData()
Application.ScreenUpdating = False
Dim LastRow As Integer, i As Integer, erow As Integer
LastRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Cells(i, 15).Value = "Yes" Then
Range(Cells(i, 1), Cells(i, 14)).Select
Selection.Copy
Workbooks.Open Filename:="path...."
Worksheets("Master").Unprotect Password:="password"
Worksheets("Master").Select
erow = Worksheets("Master").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Worksheets("Master").Cells(erow, 1).Select
Worksheets("Master").Paste
ActiveWorkbook.Save
Worksheets("Master").Protect Password:="password"
ActiveWorkbook.Close
Application.CutCopyMode = False
End If
Next i
Application.ScreenUpdating = True
End Sub