Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Unprotect only certain cells after macros runs to unhide range of

I have the following code which of course based on a checkboxthe person
selects unprotects the worksheet, unhides the specified range of rows and
then reprotects the workbook. As well if they un-check that checkbox it
will rehide those rows. I am creating this for a group of employees.

Here is my code:
------------------------------------------------------
Private Sub CheckBox1_Click()
'More then 1000 pr year
If CheckBox1 = True Then
Worksheets("Estimate").Unprotect "ds789"
Range(Rows(118), Rows(142)).EntireRow.Hidden = False
ElseIf CheckBox1 = False Then
Range(Rows(68), Rows(142)).EntireRow.Hidden = True
Worksheets("Estimate").Protect "ds789"
End If
End Sub

Private Sub CheckBox2_Click()
'For Lots 25 to 1000 pr year
If CheckBox2 = True Then
Worksheets("Estimate").Unprotect "ds789"
Range(Rows(92), Rows(117)).EntireRow.Hidden = False
ElseIf CheckBox2 = False Then
Range(Rows(68), Rows(141)).EntireRow.Hidden = True
Worksheets("Estimate").Protect "ds789"
End If
End Sub

Private Sub CheckBox3_Click()
'For Lots 1 to 25 pr year
If CheckBox3 = True Then
Worksheets("Estimate").Unprotect "ds789"
Range(Rows(66), Rows(92)).EntireRow.Hidden = False
ElseIf CheckBox3 = False Then
Range(Rows(68), Rows(141)).EntireRow.Hidden = True
Worksheets("Estimate").Protect "ds789"
End If

End Sub
--------------------------------------------------

So now what I need to do is specify in there to only allow certain cells in
those rows to be filled in. For example if they check checkbox1 then I need
to unhide the rows specified but then only allow entry in the range c71:c77.
I am thinking there has to be a way to do but I only know certain areas of
visual basic programming code and its been as I go I learn. I would greatly
appreciate anyone's assistance with this.
~M
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Unprotect only certain cells after macros runs to unhide range of

I think you have to unprotect the sheet, unlock the range of cells desired

Range().Locked = False

and reprotect the sheet. (Then vice-versa to relock the cells.)

"MiComputerGeek78" wrote:

I have the following code which of course based on a checkboxthe person
selects unprotects the worksheet, unhides the specified range of rows and
then reprotects the workbook. As well if they un-check that checkbox it
will rehide those rows. I am creating this for a group of employees.

Here is my code:
------------------------------------------------------
Private Sub CheckBox1_Click()
'More then 1000 pr year
If CheckBox1 = True Then
Worksheets("Estimate").Unprotect "ds789"
Range(Rows(118), Rows(142)).EntireRow.Hidden = False
ElseIf CheckBox1 = False Then
Range(Rows(68), Rows(142)).EntireRow.Hidden = True
Worksheets("Estimate").Protect "ds789"
End If
End Sub

Private Sub CheckBox2_Click()
'For Lots 25 to 1000 pr year
If CheckBox2 = True Then
Worksheets("Estimate").Unprotect "ds789"
Range(Rows(92), Rows(117)).EntireRow.Hidden = False
ElseIf CheckBox2 = False Then
Range(Rows(68), Rows(141)).EntireRow.Hidden = True
Worksheets("Estimate").Protect "ds789"
End If
End Sub

Private Sub CheckBox3_Click()
'For Lots 1 to 25 pr year
If CheckBox3 = True Then
Worksheets("Estimate").Unprotect "ds789"
Range(Rows(66), Rows(92)).EntireRow.Hidden = False
ElseIf CheckBox3 = False Then
Range(Rows(68), Rows(141)).EntireRow.Hidden = True
Worksheets("Estimate").Protect "ds789"
End If

End Sub
--------------------------------------------------

So now what I need to do is specify in there to only allow certain cells in
those rows to be filled in. For example if they check checkbox1 then I need
to unhide the rows specified but then only allow entry in the range c71:c77.
I am thinking there has to be a way to do but I only know certain areas of
visual basic programming code and its been as I go I learn. I would greatly
appreciate anyone's assistance with this.
~M

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
Unhide, Unprotect, Enter Password Don[_3_] Excel Worksheet Functions 2 January 20th 10 03:20 PM
Unhide column if range of cells contain data wizardmalcolm Excel Worksheet Functions 0 July 28th 09 12:11 PM
Creating Macro to Unprotect and unhide Mandy Excel Discussion (Misc queries) 2 August 7th 08 12:29 PM
I need a macro that runs other macros until P5=28 Jeff Excel Discussion (Misc queries) 6 May 7th 08 11:44 PM
Unprotect a range of cells in a protected worksheet N.B.Pitkar Excel Discussion (Misc queries) 1 October 1st 07 05:21 AM


All times are GMT +1. The time now is 02:59 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"