J
Julian Milano
Dim ws As Worksheet
.....
Private Sub ProtectAllWS()
For Each ws In Worksheets
ws.Cells(1, 1).Select
ws.Protect Password:="yes"
Next ws
End Sub
It fails on the line "ws.Cells(1, 1).Select" with the error "Select method
of range class failed". Why?
I tried "sheets(1).cells(1,1).select" and it works fine.
OK, so what I found was that the sheet had to be visible/active before the
code above would work. How do I cahnge the code so that I do not have to
select the worksheet first before setting [A1] as the selection?
.....
Private Sub ProtectAllWS()
For Each ws In Worksheets
ws.Cells(1, 1).Select
ws.Protect Password:="yes"
Next ws
End Sub
It fails on the line "ws.Cells(1, 1).Select" with the error "Select method
of range class failed". Why?
I tried "sheets(1).cells(1,1).select" and it works fine.
OK, so what I found was that the sheet had to be visible/active before the
code above would work. How do I cahnge the code so that I do not have to
select the worksheet first before setting [A1] as the selection?