+ Reply to Thread
Results 1 to 9 of 9

Changing the value of a protected cell

  1. #1
    Shawn
    Guest

    Changing the value of a protected cell


    Sub go()
    Dim goal As Range
    Set goal = Sheets("sheet1").Range("A1")

    Range("A1") = goal + 1
    End Sub

    I get an error because this is on a protected sheet and protected cell. How
    can I get result without having to unprotect the sheet?


    --
    Thanks
    Shawn

  2. #2
    Paul T.
    Guest

    Re: Changing the value of a protected cell

    You must either unlock the cell prior to protecting it, or unprotect
    the sheet, change value, and then protect again. There is no other way
    around it, or there would be no point to protecting it. If it is a
    cell that I dont mind users editing, I unlock it, otherwise I do the
    unprotect, change, protect method.


  3. #3
    NickHK
    Guest

    Re: Changing the value of a protected cell

    Shawn,
    Look at the arguments for the Protect method.
    You have an option of UIOnly (or something like that). That means that the
    user cannot change the sheet, but code can.

    NickHK

    "Shawn" <[email protected]> 级糶秎ン穝籇:[email protected]...
    >
    > Sub go()
    > Dim goal As Range
    > Set goal = Sheets("sheet1").Range("A1")
    >
    > Range("A1") = goal + 1
    > End Sub
    >
    > I get an error because this is on a protected sheet and protected cell.
    > How
    > can I get result without having to unprotect the sheet?
    >
    >
    > --
    > Thanks
    > Shawn




  4. #4
    Tom Ogilvy
    Guest

    RE: Changing the value of a protected cell

    Assuming you don't want to unlock the cell before you protect the sheet, then

    Sub go()
    Dim goal As Range
    Set goal = Sheets("sheet1").Range("A1")
    ActiveSheet.Unprotect Password:="ABC"
    Range("A1") = goal + 1
    Activesheet.Protect Password:="ABC"
    End Sub

    --
    Regards,
    Tom Ogilvy



    "Shawn" wrote:

    >
    > Sub go()
    > Dim goal As Range
    > Set goal = Sheets("sheet1").Range("A1")
    >
    > Range("A1") = goal + 1
    > End Sub
    >
    > I get an error because this is on a protected sheet and protected cell. How
    > can I get result without having to unprotect the sheet?
    >
    >
    > --
    > Thanks
    > Shawn


  5. #5
    Dave Peterson
    Guest

    Re: Changing the value of a protected cell

    UserInterfaceOnly = UIOnly

    (just a clarification)

    NickHK wrote:
    >
    > Shawn,
    > Look at the arguments for the Protect method.
    > You have an option of UIOnly (or something like that). That means that the
    > user cannot change the sheet, but code can.
    >
    > NickHK
    >
    > "Shawn" <[email protected]> 级糶秎ン穝籇:[email protected]...
    > >
    > > Sub go()
    > > Dim goal As Range
    > > Set goal = Sheets("sheet1").Range("A1")
    > >
    > > Range("A1") = goal + 1
    > > End Sub
    > >
    > > I get an error because this is on a protected sheet and protected cell.
    > > How
    > > can I get result without having to unprotect the sheet?
    > >
    > >
    > > --
    > > Thanks
    > > Shawn


    --

    Dave Peterson

  6. #6
    NickHK
    Guest

    Re: Changing the value of a protected cell

    Dave,
    Thanks.
    I'm currently on a Chinese system without Office installed, so it was
    guesswork.

    NickHK

    "Dave Peterson" <[email protected]>
    ???????:[email protected]...
    > UserInterfaceOnly = UIOnly
    >
    > (just a clarification)
    >
    > NickHK wrote:
    >>
    >> Shawn,
    >> Look at the arguments for the Protect method.
    >> You have an option of UIOnly (or something like that). That means that
    >> the
    >> user cannot change the sheet, but code can.
    >>
    >> NickHK
    >>
    >> "Shawn" <[email protected]>
    >> 级糶秎ン穝籇:[email protected]...
    >> >
    >> > Sub go()
    >> > Dim goal As Range
    >> > Set goal = Sheets("sheet1").Range("A1")
    >> >
    >> > Range("A1") = goal + 1
    >> > End Sub
    >> >
    >> > I get an error because this is on a protected sheet and protected cell.
    >> > How
    >> > can I get result without having to unprotect the sheet?
    >> >
    >> >
    >> > --
    >> > Thanks
    >> > Shawn

    >
    > --
    >
    > Dave Peterson




  7. #7
    Dave Peterson
    Guest

    Re: Changing the value of a protected cell

    Wow!

    You live in interesting times.

    (not meant as a Chinese curse!)

    NickHK wrote:
    >
    > Dave,
    > Thanks.
    > I'm currently on a Chinese system without Office installed, so it was
    > guesswork.
    >
    > NickHK
    >
    > "Dave Peterson" <[email protected]>
    > ???????:[email protected]...
    > > UserInterfaceOnly = UIOnly
    > >
    > > (just a clarification)
    > >
    > > NickHK wrote:
    > >>
    > >> Shawn,
    > >> Look at the arguments for the Protect method.
    > >> You have an option of UIOnly (or something like that). That means that
    > >> the
    > >> user cannot change the sheet, but code can.
    > >>
    > >> NickHK
    > >>
    > >> "Shawn" <[email protected]>
    > >> 级糶秎ン穝籇:[email protected]...
    > >> >
    > >> > Sub go()
    > >> > Dim goal As Range
    > >> > Set goal = Sheets("sheet1").Range("A1")
    > >> >
    > >> > Range("A1") = goal + 1
    > >> > End Sub
    > >> >
    > >> > I get an error because this is on a protected sheet and protected cell.
    > >> > How
    > >> > can I get result without having to unprotect the sheet?
    > >> >
    > >> >
    > >> > --
    > >> > Thanks
    > >> > Shawn

    > >
    > > --
    > >
    > > Dave Peterson


    --

    Dave Peterson

  8. #8
    NickHK
    Guest

    Re: Changing the value of a protected cell

    Dave,
    Interesting times for sure, but also Hong Kong, so not surprising really.

    NickHK

    "Dave Peterson" <[email protected]>
    ???????:[email protected]...
    > Wow!
    >
    > You live in interesting times.
    >
    > (not meant as a Chinese curse!)
    >
    > NickHK wrote:
    >>
    >> Dave,
    >> Thanks.
    >> I'm currently on a Chinese system without Office installed, so it was
    >> guesswork.
    >>
    >> NickHK
    >>
    >> "Dave Peterson" <[email protected]>
    >> ???????:[email protected]...
    >> > UserInterfaceOnly = UIOnly
    >> >
    >> > (just a clarification)
    >> >
    >> > NickHK wrote:
    >> >>
    >> >> Shawn,
    >> >> Look at the arguments for the Protect method.
    >> >> You have an option of UIOnly (or something like that). That means that
    >> >> the
    >> >> user cannot change the sheet, but code can.
    >> >>
    >> >> NickHK
    >> >>
    >> >> "Shawn" <[email protected]>
    >> >> 级糶秎ン穝籇:[email protected]...
    >> >> >
    >> >> > Sub go()
    >> >> > Dim goal As Range
    >> >> > Set goal = Sheets("sheet1").Range("A1")
    >> >> >
    >> >> > Range("A1") = goal + 1
    >> >> > End Sub
    >> >> >
    >> >> > I get an error because this is on a protected sheet and protected
    >> >> > cell.
    >> >> > How
    >> >> > can I get result without having to unprotect the sheet?
    >> >> >
    >> >> >
    >> >> > --
    >> >> > Thanks
    >> >> > Shawn
    >> >
    >> > --
    >> >
    >> > Dave Peterson

    >
    > --
    >
    > Dave Peterson




  9. #9
    Shawn
    Guest

    RE: Changing the value of a protected cell

    I have decided to use sort of a back door method. I am going to make that
    cell a formula equal to a value in another sheet that is unprotected.
    --
    Thanks
    Shawn


    "Shawn" wrote:

    >
    > Sub go()
    > Dim goal As Range
    > Set goal = Sheets("sheet1").Range("A1")
    >
    > Range("A1") = goal + 1
    > End Sub
    >
    > I get an error because this is on a protected sheet and protected cell. How
    > can I get result without having to unprotect the sheet?
    >
    >
    > --
    > Thanks
    > Shawn


+ 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