L
Legacy 436357
Guest
Hello,
I have this code to put data on the 'Service Log'! sheet. I want to keep that sheet protected but the code won't run unless I keep the sheet unprotected.
Can there be lines added so it will unprotect the 'Service Log'! and protect again please?
Thank you
I have this code to put data on the 'Service Log'! sheet. I want to keep that sheet protected but the code won't run unless I keep the sheet unprotected.
Can there be lines added so it will unprotect the 'Service Log'! and protect again please?
Thank you
Code:
Sub CopyPasteRows1()
Dim lr As Long
Dim r As Long
Dim nr As Long
Application.ScreenUpdating = False
' Find last row with data in column on Sheet3
lr = Sheets("2011 Ford F150").Cells(Rows.Count, "C").End(xlUp).Row
' Loop through all rows starting on row 2 on Sheet2
For r = 2 To lr
If Sheets("2011 Ford F150").Cells(r, "P") = True Then
' Find next available row on Sheet2
nr = Sheets("Service Log").Cells(Rows.Count, "C").End(xlUp).Row + 1
' Copy data to from columns C-K to Sheet2
Sheets("2011 Ford F150").Range("C" & r).Resize(, 9).Copy
' Paste values from columns C-K to Sheet2
Sheets("Service Log").Cells(nr, "C").PasteSpecial xlPasteValues
' Remove checkbox from Sheet3
Sheets("2011 Ford F150").Cells(r, "P") = False
End If
Next r
' Clears colums H,I, and K after code runs
Worksheets("2011 Ford F150").Range("H7:I40").ClearContents
Worksheets("2011 Ford F150").Range("K7:K40").ClearContents
Application.ScreenUpdating = True
Application.CutCopyMode = False
MsgBox "Service entries have been posted to 'Service Log'!"
End Sub