how to make the content in an excel cell read only?!

S

Simon Lloyd

*how to make the content in an excel cell read only?!* Firstly you have to make sure the cells attributes are locked (righ
click, format cells, protection) they are locked by default, the
protect the sheet, the cell can then only be read not edited. To b
honest you need to explain more what you want to do

--
Simon Lloy

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com
 
N

NA_AB

well, am actually working with c# and developing an excel addin. I need to
make some excel cells, having some text, read-only and the rest of the sheet
is free to any modifications by the user.

Regards.
 
S

Simon Lloyd

The same applies!, either that or specifically name them in an intersec
range, and make it so that cell cannot be selected, but of course if yo
are doing that macro's have to be enabled

NA_AB;189924 said:
well, am actually working with c# and developing an excel addin. I nee
t
make some excel cells, having some text, read-only and the rest of th
shee
is free to any modifications by the user

Regards



have to make sure the cells attributes are locked (righ

Lloyd' (http://www.thecodecage.com/forumz/member.php?userid=1
only?! - The Code Cage Forums
(http://www.thecodecage.com/forumz/showthread.php?t=52319

--
Simon Lloy

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com
 
S

Simon Lloyd

Here's just a quick sample, put it in the code module for the worksheet

Code
-------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range
If Not Intersect(Target, Range("A1:A10,B2,C5:D10")) Is Nothing The
MsgBox "You cannot select that cell!, you will now be moved to the next cell to the right!"
, vbOKOnly, "Invalid Cell Choice
ActiveCell.Offset(0, 1).Selec
End I
End Su
-------------------
The same applies!, either that or specifically name them in an intersec
range, and make it so that cell cannot be selected, but of course if yo
are doing that macro's have to be enabled

--
Simon Lloy

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com
 
D

DM

Select Cell
Data -> Validation -> Setttings -> Validation Criteria -> Select "Custom" ->
in Formula enter "=" (equal sign)
That's it. Excel will not allow you to change value
 
N

NA_AB

hey sorry ppl but i would appreciate if i can be provided with a simple code
which may be appear like, ((Range)myapp.cells[r,c]).isreadonly() or something
like that, cuz there are many different cells that i would want to make read
only and many others editable(read n write). And simon, truly speaking, i do
not want to transfer user control to any other cell. Am basically building an
excel com add-in using visual studio and c#.net tech. I can access a range of
cell/ cells in my current application's active sheet and in this sheet i
should be able to make some cells read only dynamically and later should also
be able to remove the constraint(read only) on the cells of my choice.

i see that many things can be done in vb but i am not able to convert or
find similar functionalities in c#, so please provide me with the code in
c#...

Regards,
na_ab
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top