Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



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
Is there a way to disable a macro based on the value of a cell? Jeff Excel Discussion (Misc queries) 1 March 7th 08 06:43 PM
enable/disable button based on cell value Shoney Excel Discussion (Misc queries) 3 January 9th 08 07:34 PM
Disable Tools Protection Protect Sheet for all users but one Win XP Excel Discussion (Misc queries) 6 January 17th 06 10:46 PM
Conditional formatting based on decision to enable/disable macros? zenahs Excel Discussion (Misc queries) 1 November 15th 05 07:40 PM
protect cells based on another cell Neil Excel Worksheet Functions 6 August 9th 05 03:13 PM


All times are GMT +1. The time now is 03:26 AM.

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"