Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default VBA for Cell locked please help

Hi

I don't seem to get any error when opening the workbook however it
doesnt do the job. I want to allow certain users to be able to amend
the content in the Worksheet but if they are not the selected users
then they can only view the data. Could anyone please advice me what I
have to do.

Thank you very much in advance. below is my code

Peddie


Private Sub Workbook_Open()


Dim username As String

username = OSUserName()

'If username = "John Smith" Then

lock_cells

'Else
'Selection.Locked = True
End Sub


Sub lock_cells()
Sheets("Apr 2006 - Mar 2007").Select
Cells.Locked = True

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default VBA for Cell locked please help

Sure, you're just missing one more step. In order to block the cells
from being changed, you not only have to lock the cells, but you have
to Protect the sheet. Try adding this in:

ActiveSheet.Protect Password:="yourpassword"

And to reverse it:

ActiveSheet.Unprotect Password:="yourpassword"


peddie wrote:
Hi

I don't seem to get any error when opening the workbook however it
doesnt do the job. I want to allow certain users to be able to amend
the content in the Worksheet but if they are not the selected users
then they can only view the data. Could anyone please advice me what I
have to do.

Thank you very much in advance. below is my code

Peddie


Private Sub Workbook_Open()


Dim username As String

username = OSUserName()

'If username = "John Smith" Then

lock_cells

'Else
'Selection.Locked = True
End Sub


Sub lock_cells()
Sheets("Apr 2006 - Mar 2007").Select
Cells.Locked = True

End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Locked worksheet & hyperlinks (w/ select locked cells unchecked) dgold82 Excel Discussion (Misc queries) 1 July 10th 09 09:42 PM
locked cell not locked Wanna Learn Excel Discussion (Misc queries) 1 December 17th 08 06:01 PM
Cell shading locked? Mike Excel Discussion (Misc queries) 1 May 30th 07 02:05 PM
Formula in Cell changes even if it's locked word 2003 help Excel Discussion (Misc queries) 3 May 19th 06 08:43 PM
Put comments on a locked spreadsheet even though cells not locked RDP Excel Worksheet Functions 1 September 11th 05 11:59 PM


All times are GMT +1. The time now is 10:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"