感谢重新调整的宏记录器(它是你的朋友!)输出并假设它在活动工作表上而不是在其他工作表上:
Sub formatAndUnlock()
Dim lCount As Long
With ActiveSheet
lCount = .Range("A65536").End(xlUp).Row
With .Range("A1:AD" & lCount + 50)
.Borders(xlEdgeLeft).Weight = xlThin
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).Weight = xlThin
.Borders(xlEdgeRight).Weight = xlThin
.Borders(xlInsideVertical).Weight = xlThin
.Borders(xlInsideHorizontal).Weight = xlThin
End With
.Range("A" & lCount +1 & ":AB" & lCount + 50).Locked = False
.Range("AC1:AD" & lCount + 50).Locked = False
End With
End Sub