Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Protect sheet from users only?

30 views
Skip to first unread message

Dave Cullen

unread,
Feb 4, 2003, 11:05:45 AM2/4/03
to
I want to lock all cells on my worksheet except Column A, which is where
the user will enter data. The rest of the worksheet should be protected.

Problem is, I have VBA code that changes the values of "protected"
cells, and it generates "Runtime error '1004' application-defined or
object-defined error" when I set protection on.

Ummm.. is there any way to protect a worksheet from user input, but
allow the VBA code to work?

Ron de Bruin

unread,
Feb 4, 2003, 11:22:56 AM2/4/03
to
ActiveSheet.Protect UserInterfaceOnly:=True

but you must run it every time you open your workbook
A good place to run it is in the Workbook open event in the
Thisworkbook module

Private Sub Workbook_Open()
Dim Sh As Worksheet
For Each Sh In ThisWorkbook.Worksheets
Sh.Protect userinterfaceonly:=True
Next
End Sub


--
Regards Ron de Bruin
(Win XP SP-1 XL2002 SP-2)
www.rondebruin.nl


"Dave Cullen" <no_...@mail.com> schreef in bericht
news:3E3FE4D9...@mail.com...

Harald Staff

unread,
Feb 4, 2003, 11:32:21 AM2/4/03
to
Hi Dave

Sure:

Sub test()
Sheets(1).Protect UserInterfaceOnly:=True
MsgBox "Locked"
Sheets(1).Cells(4, 4).Value = "See ? Locked cell entry !"
End Sub

HTH. Best wishes Harald

"Dave Cullen" <no_...@mail.com> wrote in message
news:3E3FE4D9...@mail.com...

0 new messages