I want to write a macro, that in all sheets locks certain cells -- from A12 to last row of R. Thing is, that I get
error 1004: "Method 'Range' Of Object '_Worksheet' failed"
in line
LastRow = wSheet.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row)
.
Could anyone help me out? Thanks!
Option Explicit
Sub ProtectAll()
Dim wSheet As Worksheet
Dim Pwd As String
Dim LastRow As Integer
Pwd = InputBox("Enter your password to protect all worksheets", "Password Input")
For Each wSheet In Worksheets
LastRow = wSheet.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
wSheet.Range(Cells(12, 1), Cells(LastRow, 18)).Select
wSheet.Protect Password:=Pwd, AllowFiltering:=True
Next wSheet
End Sub