+ Reply to Thread
Results 1 to 2 of 2

Unprotect only certain cells after macros runs to unhide range of

  1. #1
    MiComputerGeek78
    Guest

    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. #2
    Charlie
    Guest

    RE: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1