ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can I set a range can't be selected! (https://www.excelbanter.com/excel-programming/330376-how-can-i-set-range-cant-selected.html)

cherishman

How can I set a range can't be selected!
 
I want set a range(one cell or more) can't be selected, so the user can't
change the values. How can I do?



Mike Fogleman

How can I set a range can't be selected!
 
Dim MyRange As Range

Set MyRange = Worksheets("Sheet1").Range("B3:D20")
Set MyRange = Activesheet.Range("A10")
Get the idea?

Mike F
"cherishman" wrote in message
...
I want set a range(one cell or more) can't be selected, so the user can't
change the values. How can I do?





Dave Peterson[_5_]

How can I set a range can't be selected!
 
You can lock those cells (as well as any other cells that shouldn't be changed)
and unlock the cells that are ok to update.

Format|Cells|protection tab
is one way of toggling that setting.

Then protect the worksheet.
tools|protection|protect sheet

Be aware that worksheet protection isn't a security measure--it's usually just
used to keep users from overwriting formulas/labels.

That worksheet protection is easily broken.

And if you really want to stop the selection--not just stop the changing...

If you protect the sheet in code, it'll work for xl97+ (as long as the macro
runs):

Option Explicit
Sub auto_open()
With Worksheets("sheet1")
.Protect Password:="hi"
.EnableSelection = xlUnlockedCells
End With
End Sub

Excel won't remember these settings after you close it and reopen the workbook
(that's why it's in auto_open).

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

cherishman wrote:

I want set a range(one cell or more) can't be selected, so the user can't
change the values. How can I do?


--

Dave Peterson


All times are GMT +1. The time now is 06:12 PM.

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