View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Making cells readonly

Sarah

Either of these will work.

Sub lockdown()
With Sheet1
For i = 1 To 3
.Columns(i).Locked = True
Next
.Protect DrawingObjects:=True, Contents:=True, _
Scenarios:=True
End With
End Sub


Sub lockdown2()
For i = 1 To 3
Sheet1.Columns(i).Locked = True
Next
Sheet1.Protect DrawingObjects:=True, Contents:=True, _
Scenarios:=True
End Sub

I still think you should go for the other scenario which unlocks all other
cells except columns 1 to 3

Gord

On Sun, 8 Feb 2004 09:56:05 -0800, "Sarah"
wrote:

When I try the code you had in your post, I get an error: "Expected statement".

Here is the line of code I am using:
sheet1.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

Is this not correct?