The macro below causes my worksheet to stop working when its protected.
I have a macro which pastes onto cells. It works to begin with as I have formatted the cells to unlocked
The macro below clears the contents but it seems to be leaving the cells protected.
So after clearing the contents with this the first macro stops working with a "sheet is protected error"
Im really hoping to have a solution which keeps the sheet protected but leaves the cleard cell unlocked so they can be rewritten on.
If anyone has any advice/solution to this problem that would be amazing. thansk
Sub ResetSims()
Dim lr As LongPtr
Dim Num As LongPtr
Dim LC As Range
Dim CopyRow As Range
Dim CopyTo As Range
Application.ScreenUpdating = False
Set LC = ActiveSheet.Rows("1:1").Find(What:="helper", LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If LC Is Nothing Then
MsgBox ("The last column of data before the top 10 must be called 'helper'")
Exit Sub
End If
lr = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Set CopyRow = ActiveSheet.Range(ActiveSheet.Cells(lr, 1), ActiveSheet.Cells(lr, LC.Column))
Set CopyTo = ActiveSheet.Range("A3")
Application.Calculation = xlManual
CopyRow.Copy Destination:=CopyTo
ActiveSheet.Range(Cells(4, 1), Cells(lr, LC.Column)).Clear
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub
Bookmarks