Try changing
Range(sRng(i)).Select
Selection.Locked = False
to
..Range(sRng(i)).Locked = False
(There is no need to select the range first.)
Note the leading ., since you are using a with construct. This
assumes that nmaed range 1 is on named sheet 1, etc.
HTH,
Bernie
MS Excel MVP
"active_x" wrote in message
...
Scripts:
Sub Macro4()
Dim sRng(1 To 10) As String, sSht(1 To 4) As String
Dim i As Integer
sSht(1) = "main"
sSht(2) = "rsImport"
sSht(3) = "rsExport"
sSht(4) = "rsStock"
sRng(1) = "input_main"
sRng(2) = "db_rsImport"
sRng(3) = "db_rsExport"
sRng(4) = "db_rsStock"
For i = 1 To 4
With Sheets(sSht(i))
'lock ALL cells in ALL sht
Cells.Locked = True
Cells.FormulaHidden = True
'unlock specific cells in main, rsImport, rsExport and rsStock
Range(sRng(i)).Select '**the error arises
from this line
Selection.Locked = False
End With 'End With Sheets(sSht(i))
Next i
End Sub
------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from
http://www.ExcelForum.com/