Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default how to make cell read only

Hi,

I have tried the following code, but doesn't work unless I protect the
sheet:
Range("A1:A4").Select
Selection.Locked = True
Selection.FormulaHidden = False

If I protect the sheet, then it works fine, but how can I make a cell
read only
WITHOUT protecting the sheet ??

Any help is appreciated.

Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default how to make cell read only

You can't, sorry.

Best wishes Harald

"ndalal" skrev i melding
ups.com...

If I protect the sheet, then it works fine, but how can I make a cell
read only
WITHOUT protecting the sheet ??



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to make cell read only


Technically you can't, but depending on your needs you can do something
as follows, where "F7" is the cell you want protected:

Private Sub Worksheet_Change(ByVal Target As Range)
Range("F7").Value = "Your Formula or Text Goes Here"
End Sub

Harald Staff Wrote:
You can't, sorry.

Best wishes Harald

"ndalal" skrev i melding
ups.com...

If I protect the sheet, then it works fine, but how can I make a

cell
read only
WITHOUT protecting the sheet ??



--
Ikaabod
------------------------------------------------------------------------
Ikaabod's Profile: http://www.excelforum.com/member.php...o&userid=33371
View this thread: http://www.excelforum.com/showthread...hreadid=540414

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to make cell read only


Also, if you're trying to prevent people from knowing what formula
you're using I would suggest having the macro calculate the formula
(instead of having the formula in the cell) and just put a value in the
cell and then you can lock your macro.


--
Ikaabod
------------------------------------------------------------------------
Ikaabod's Profile: http://www.excelforum.com/member.php...o&userid=33371
View this thread: http://www.excelforum.com/showthread...hreadid=540414

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default how to make cell read only

Hi,
You could use a Worksheet_Change Sub to kick the user out of A1:A4
should they ever try to click into any of those four cells.

If that would do then just paste this into that worksheet's code
module...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(ActiveCell, Range("A1:A4")) Is Nothing Then
Range("B1").Select
End If
End Sub

Ken Johnson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to make cell read only


This is also true, but be careful when using this method because you can
still select B4:A1 and delete/edit the contents.

Ken Johnson Wrote:
Hi,
You could use a Worksheet_Change Sub to kick the user out of A1:A4
should they ever try to click into any of those four cells.

If that would do then just paste this into that worksheet's code
module...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(ActiveCell, Range("A1:A4")) Is Nothing Then
Range("B1").Select
End If
End Sub

Ken Johnson



--
Ikaabod
------------------------------------------------------------------------
Ikaabod's Profile: http://www.excelforum.com/member.php...o&userid=33371
View this thread: http://www.excelforum.com/showthread...hreadid=540414

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default how to make cell read only

Hi Ikaabod,

Good point!

How about...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Selection, Range("A1:A4")) Is Nothing Then
Range("B1").Select
End If
End Sub

Ken Johnson

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default how to make cell read only

Thanks a lot for all the good points. I will try them out today and let
you guys know.

That was great help....really appreciate it.

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default how to make cell read only

Ken, do you have a way to make the whole column read only?

Ikaabod, your solution works only if the cell has fixed data, however
my data keeps changing in those cells so Ken's solution works better.

- Nirav

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to make cell read only


Ken's last suggestion is probably the best. If you want the entire
column just change:
If Not Intersect(Selection, Range("A1:A4"))
to
If Not Intersect(Selection, Range("A:A"))

ndalal Wrote:
Ken, do you have a way to make the whole column read only?

Ikaabod, your solution works only if the cell has fixed data, however
my data keeps changing in those cells so Ken's solution works better.

- Nirav



--
Ikaabod
------------------------------------------------------------------------
Ikaabod's Profile: http://www.excelforum.com/member.php...o&userid=33371
View this thread: http://www.excelforum.com/showthread...hreadid=540414



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
How do I format cells in Excel to make 175/5 read 175? SJR4347 Excel Worksheet Functions 2 February 22nd 10 03:21 AM
How do I make an execl cell A3 read-only based on A4? Jerome Excel Discussion (Misc queries) 3 September 10th 09 09:39 PM
How do I make read-only file vij Excel Discussion (Misc queries) 1 July 17th 09 02:04 PM
Make a file read only Michael Singmin Excel Programming 1 November 3rd 03 07:45 PM
How do make cells F9:R1999 READ-ONLY ? lothario[_12_] Excel Programming 3 October 14th 03 09:09 PM


All times are GMT +1. The time now is 05:13 PM.

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

About Us

"It's about Microsoft Excel"