Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Lock Range of Cells

Hi,

I have the following code that isn't working to lock the range of cells
listed on ss selected. By applying activesheet.protect, do I still need to
go to formatcells or toolsprotection and set a password to protect this
sheet or does this line of code provide for that?

Sub DTProtectWhiteSpaceAllProd()
Worksheets("DT").Select
Cells.Select
Selection.Locked = False
Range("A146:A160").Select
Selection.Locked = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
End Sub

If anyone can tell me what I'm doing wrong I would appreciate it.
Thanks,
Pam


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default Lock Range of Cells

You code tests OK for me. One minor suggestion is to unlock the sheet before
running your code.


Sub DTProtectNoPassword()
Worksheets("DT").Select
ActiveSheet.Unprotect 'enure it is unlocked
Cells.Select
Selection.Locked = False
Range("A1:A16").Select
Selection.Locked = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
End Sub

Sub ProtWithPW()

Worksheets("DT").Select
ActiveSheet.Unprotect Password:="yourPassword"
Cells.Select
Selection.Locked = False
Range("A1:A16").Select
Selection.Locked = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True, Password:="yourPassword"

End Sub


--
Steve

"Pam" wrote in message
...
Hi,

I have the following code that isn't working to lock the range of cells
listed on ss selected. By applying activesheet.protect, do I still need
to go to formatcells or toolsprotection and set a password to protect
this sheet or does this line of code provide for that?

Sub DTProtectWhiteSpaceAllProd()
Worksheets("DT").Select
Cells.Select
Selection.Locked = False
Range("A146:A160").Select
Selection.Locked = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
End Sub

If anyone can tell me what I'm doing wrong I would appreciate it.
Thanks,
Pam

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
Lock or Unlock Range of Cells on Worksheet_Change Event Grahame Coyle Excel Worksheet Functions 3 July 14th 08 12:27 AM
How do i can lock more than one range in worksheet Nazr-ul-Haque Excel Discussion (Misc queries) 2 August 26th 07 03:06 PM
Excel should lock individual cells or range only centrality Excel Worksheet Functions 1 June 30th 06 08:06 PM
Lock Cells with Specify Range If Cells contains value bernardng[_5_] Excel Programming 0 June 13th 06 05:23 AM
Unable to Lock a Range Stuart[_5_] Excel Programming 7 July 10th 04 06:06 PM


All times are GMT +1. The time now is 10:55 PM.

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"