Solved Excel 2007 VBA locking cells

April 18, 2012 at 14:15:05
Specs: Windows XP
Ok, what I need seems to be easy but I cant get to the correct code.

All I need is to "lock" cell G33.

The form is password protected and i alerady have the the unprotect at the beginning and protect at the end. I Just need to LOCK Cell G33 after running the macro.
G33 is a merged cell if that makes a difference... it is "G33:I33" the cell I want to lock

What am I doing wrong?

Sub Macro1()

Dim attachmateapp As Object
Dim currsession As Object
Dim myscreen As Object
Dim screenname As String
Dim locationCode As String

Set attachmateapp = CreateObject("Extra.System")
Set currsession = attachmateapp.Activesession
Set myscreen = currsession.Screen

'Protection off!
ActiveSheet.Unprotect Password:=""

'Dont allow checks to be added after running the macro
ActiveSheet.Cells.Locked = False
ActiveSheet.Range("G33").Locked = True

'protection on!
ActiveSheet.Protect Password:=""

End Sub

Thanks for the help everyone

See More: Excel 2007 VBA locking cells

April 18, 2012 at 17:45:34
✔ Best Answer
It might help us help you if you told us what was happening when you try to lock the cell.

Does it just not lock? Do you get an error? Something else?

In any case, have you tried this:

ActiveSheet.Range("G33:I33").Locked = True

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

Report •

April 19, 2012 at 07:02:02
Im a moron. It works!

ActiveSheet.Range("G33:I33").Locked = True

Thanks a lot!!!!!!

Report •
Related Solutions

Ask Question