ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   disabling a cell in excel (https://www.excelbanter.com/excel-programming/339008-disabling-cell-excel.html)

[email protected]

disabling a cell in excel
 
How can I disable a cell using VBA in Excel. I want fill in a value in
the cell and then grey it out so that user can just see the value but
cannot edit it.

Your help is much appreciated.
regards


Rowan[_4_]

disabling a cell in excel
 
The simplest way would be to use worksheet protection. If it is the only cell
you want to protect then:

Sub prt()
With ActiveSheet
.Cells.Locked = False
With Range("B4")
.Value = "MyValue"
.Interior.ColorIndex = 15
.Locked = True
End With
.Protect Password:="mypassword"
End With
End Sub

Hope this helps
Rowan

" wrote:

How can I disable a cell using VBA in Excel. I want fill in a value in
the cell and then grey it out so that user can just see the value but
cannot edit it.

Your help is much appreciated.
regards



[email protected]

disabling a cell in excel
 
This is exactly what I wanted.

Thank you very much for taking time to come up with the solution.

regards



All times are GMT +1. The time now is 11:03 PM.

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