Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 181
Default lock cells with values

with below statements

Range("A1:P30").Select
Selection.SpecialCells(xlCellTypeFormulas, 23).Select
Selection.Locked = True

I can select a range and then lock any cell with formulas...

How do I do same but want to lock any cell with formulas and/or values?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default lock cells with values

Hi,

Dim MyRange As Range
Set MyRange = Range("A1:P30").SpecialCells(xlCellTypeConstants)
Range("A1:P30").SpecialCells(xlCellTypeFormulas).S elect
Set MyRange = Union(MyRange, Selection)
MyRange.Locked = True

Locking has no effect until the sheet is protected.

Mike

"Alberto Ast" wrote:

with below statements

Range("A1:P30").Select
Selection.SpecialCells(xlCellTypeFormulas, 23).Select
Selection.Locked = True

I can select a range and then lock any cell with formulas...

How do I do same but want to lock any cell with formulas and/or values?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default lock cells with values

with below statements

Range("A1:P30").Select
Selection.SpecialCells(xlCellTypeFormulas, 23).Select
Selection.Locked = True

I can select a range and then lock any cell with formulas...


On Error Resume Next
Range("A1:P30").SpecialCells(xlCellTypeFormulas).L ocked = True

How do I do same but want to lock any cell with formulas and/or values?


On Error Resume Next
Union(Range("A1:P30").SpecialCells(xlCellTypeConst ants), _
Range("A1:P30").SpecialCells(xlCellTypeFormulas)). Locked = True

--
Rick (MVP - Excel)


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 Axis Values? Ryan Charts and Charting in Excel 4 April 22nd 23 09:01 AM
Any way to Lock format but not the values? lbbss Excel Discussion (Misc queries) 9 November 20th 08 03:02 AM
how do I lock values in excel nupe1493 Excel Worksheet Functions 1 June 15th 06 06:55 PM
How do I lock cells so their values don't get updated AndrewOZ Excel Programming 2 March 29th 06 04:16 AM
Lock cells for combo box values only Daniel Excel Programming 4 December 28th 05 07:22 PM


All times are GMT +1. The time now is 04:37 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"