View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Lock a Cell or Row

One way is to just have your code unprotect the sheet, do its changes and
reprotect the sheet.

with worksheets("sheet99")
.unprotect password:="hithere"
'do the work
.protect password:="hithere"
end with

An alternative is to protect the sheet in code.

Option Explicit
Sub auto_open()
With Worksheets("sheet99")
.Protect Password:="hithere", userinterfaceonly:=True
End With
End Sub

It needs to be reset each time you open the workbook. (excel doesn't remember
it after closing the workbook.)

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

There are a few things that your macro won't be able to do--so test your code
before you distribute the workbook.

afmullane wrote:

Hi Tom,

Thanks for your help Tom but do you know of a way of locking a cell
from the user but that the cell can still be manipulated through VBA
code??

Aidan

--
afmullane
------------------------------------------------------------------------
afmullane's Profile: http://www.excelforum.com/member.php...o&userid=33567
View this thread: http://www.excelforum.com/showthread...hreadid=538431


--

Dave Peterson