ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Disable/Protect Cells based on If (https://www.excelbanter.com/excel-programming/311886-disable-protect-cells-based-if.html)

bforster1[_15_]

Disable/Protect Cells based on If
 

Is it possible to have code that protects cells based on an i
statement. I have the following code that unhides certain rows if th
user selects "Units" from the ComboBox. I would like other cells to b
protected if the user selects "Units" and then unprotect if no
"Units".

Private Sub ComboBox1_Change()
If Worksheets("Sheet1").Range("J18").Value = "Units" Then
Rows("25:28").Select
Selection.EntireRow.Hidden = True
Rows("25:28").Select
Selection.EntireRow.Hidden = False
End If
If Worksheets("Sheet1").Range("J18").Value = "Input" Then
Rows("25:28").Select
Selection.EntireRow.Hidden = True
Rows("25:25").Select
Selection.EntireRow.Hidden = False
Range("B13").Select
End If

Thanks

--
bforster
-----------------------------------------------------------------------
bforster1's Profile: http://www.excelforum.com/member.php...fo&userid=1177
View this thread: http://www.excelforum.com/showthread.php?threadid=26466


Tom Ogilvy

Disable/Protect Cells based on If
 
sure. In the same code, unprotect the sheet. Toggle the locked property of
the cells, protect the sheet.

--
Regards,
Tom Ogilvy

"bforster1" wrote in message
...

Is it possible to have code that protects cells based on an if
statement. I have the following code that unhides certain rows if the
user selects "Units" from the ComboBox. I would like other cells to be
protected if the user selects "Units" and then unprotect if not
"Units".

Private Sub ComboBox1_Change()
If Worksheets("Sheet1").Range("J18").Value = "Units" Then
Rows("25:28").Select
Selection.EntireRow.Hidden = True
Rows("25:28").Select
Selection.EntireRow.Hidden = False
End If
If Worksheets("Sheet1").Range("J18").Value = "Input" Then
Rows("25:28").Select
Selection.EntireRow.Hidden = True
Rows("25:25").Select
Selection.EntireRow.Hidden = False
Range("B13").Select
End If

Thanks.


--
bforster1
------------------------------------------------------------------------
bforster1's Profile:

http://www.excelforum.com/member.php...o&userid=11771
View this thread: http://www.excelforum.com/showthread...hreadid=264663





All times are GMT +1. The time now is 09:02 AM.

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