ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Lock a Cell or Row (https://www.excelbanter.com/excel-programming/360441-lock-cell-row.html)

afmullane[_7_]

Lock a Cell or Row
 

Hi Guys,

I want to lock a cell or row so that the user of the spreadseet won't
be able to edit the contents of the cell or row.

Any help would be greatly appreciated,

Aidan


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


Tom Ogilvy

Lock a Cell or Row
 
select the cells/rows/ranges

format=Cells=Protection Tab, click Locked

then
Tools=Protect sheet

--
Regards,
Tom Ogilvy


"afmullane" wrote:


Hi Guys,

I want to lock a cell or row so that the user of the spreadseet won't
be able to edit the contents of the cell or row.

Any help would be greatly appreciated,

Aidan


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



Tom Ogilvy

Lock a Cell or Row
 
I should add that all cells by default are Locked. this is not applied
until the sheet is protected - so in practicality, you need to select the
cells you want the user to have access to and do

format=Cells=Protection tab and click unlocked. Then protect the sheet.

--
Regards,
Tom Ogilvy


"afmullane" wrote:


Hi Guys,

I want to lock a cell or row so that the user of the spreadseet won't
be able to edit the contents of the cell or row.

Any help would be greatly appreciated,

Aidan


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



afmullane[_8_]

Lock a Cell or Row
 

Hi Tom,

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

Aida

--
afmullan
-----------------------------------------------------------------------
afmullane's Profile: http://www.excelforum.com/member.php...fo&userid=3356
View this thread: http://www.excelforum.com/showthread.php?threadid=53843


Dave Peterson

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


All times are GMT +1. The time now is 09:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com