+ Reply to Thread
Results 1 to 9 of 9

Check box help please!

  1. #1
    Registered User
    Join Date
    08-08-2005
    Posts
    3

    Check box help please!

    I have form that I am working on that has approximately 120 check boxes (I used the forms check boxes). I read previous threads about creating a macro to clear out the checks, which I have done successfully, but I would like the macro to do one more thing ... After clearing out all of the checks, I would like it to place checks on a range of check boxes.

    I thought I could use the following script, but it doesn't work when the sheet is protected.

    Sub UnCheckBox()

    With Sheet1

    .CheckBoxes.Value = False

    Range("N55:N209").Select
    Selection.Replace What:="FALSE", Replacement:="TRUE", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False

    End With

    End Sub


    Can someone help please?

    Thanks!

  2. #2
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    have the macro 'unprotect' the sheet, run the code and 'reprotect' the sheet.

    good luck
    Bruce
    The older I get, the better I used to be.
    USA

  3. #3
    Registered User
    Join Date
    08-08-2005
    Posts
    3
    Can you tell me how I would do that in the script? I'm fairly new to using visual basic.

    Thanks in advance,

    Jae

  4. #4
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    ActiveSheet.UnProtect
    'your code here
    ActiveSheet.Protect

    HTH

    Bruce

  5. #5
    Registered User
    Join Date
    08-08-2005
    Posts
    3
    Bruce,

    Thanks for all your help. One more question, how do I incorporate a password to this script?

    Jae

  6. #6
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    We will assume you have used the password "Lock" to protect your sheet. Use this code:

    ActiveSheet.UnProtect Lock
    'your code here
    ActiveSheet.Protect Lock

    of course, adjust the password to meet your needs.

    Reminder: passwords on sheets only stop someone from inadvertantly changing data. Any one so inclined can break an Excel password in a matter of a few minutes!

    HTH

    Bruce

  7. #7
    Jae
    Guest

    Re: Check box help please!

    Bruce,

    Thanks again. I ran across a problem though ... It appears as though the
    password to protect the sheet does not get re-applied. Will you look at my
    script and advise?

    Thanks again!

    Sub UnCheckBox()

    ActiveSheet.Unprotect abc123

    With Sheet1

    ..CheckBoxes.Value = False

    Range("N55:N209").Select
    Selection.Replace What:="FALSE", Replacement:="TRUE", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False

    ActiveSheet.Protect abc123


    End With

    End Sub


    "swatsp0p" wrote:

    >
    > We will assume you have used the password "Lock" to protect your sheet.
    > Use this code:
    >
    > ActiveSheet.UnProtect Lock
    > 'your code here
    > ActiveSheet.Protect Lock
    >
    > of course, adjust the password to meet your needs.
    >
    > Reminder: passwords on sheets only stop someone from inadvertantly
    > changing data. Any one so inclined can break an Excel password in a
    > matter of a few minutes!
    >
    > HTH
    >
    > Bruce
    >
    >
    > --
    > swatsp0p
    >
    >
    > ------------------------------------------------------------------------
    > swatsp0p's Profile: http://www.excelforum.com/member.php...o&userid=15101
    > View this thread: http://www.excelforum.com/showthread...hreadid=393973
    >
    >


  8. #8
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    typo on my part, sorry... code should read:

    [vba]
    Sub UnCheckBox()

    ActiveSheet.Unprotect Password:="abc123"
    With Sheet1

    .CheckBoxes.Value = False

    Range("N55:N209").Select
    Selection.Replace What:="FALSE", Replacement:="TRUE", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False

    End With

    ActiveSheet.Protect Password:="abc123"

    End Sub[/vba]
    Does this work for you?

    Bruce

  9. #9
    Jae
    Guest

    Re: Check box help please!

    Bruce, you're a life saver. Thanks for all you help. Jae

    "swatsp0p" wrote:

    >
    > typo on my part, sorry... code should read:
    >
    >
    > Sub UnCheckBox()
    >
    > ActiveSheet.Unprotect Password:="abc123"
    > With Sheet1
    >
    > .CheckBoxes.Value = False
    >
    > Range("N55:N209").Select
    > Selection.Replace What:="FALSE", Replacement:="TRUE", LookAt:=xlPart,
    > _
    > SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    > ReplaceFormat:=False
    >
    > End With
    >
    > ActiveSheet.Protect Password:="abc123"
    >
    > End Sub
    > Does this work for you?
    >
    > Bruce
    >
    >
    > --
    > swatsp0p
    >
    >
    > ------------------------------------------------------------------------
    > swatsp0p's Profile: http://www.excelforum.com/member.php...o&userid=15101
    > View this thread: http://www.excelforum.com/showthread...hreadid=393973
    >
    >


+ 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