+ Reply to Thread
Results 1 to 8 of 8

ActiveX checkbox to unlock cell and set allow override

Hybrid View

storminasu ActiveX checkbox to unlock... 04-18-2019, 11:22 AM
StephenR Re: ActiveX checkbox to... 04-18-2019, 11:24 AM
storminasu Re: ActiveX checkbox to... 04-18-2019, 11:39 AM
StephenR Re: ActiveX checkbox to... 04-18-2019, 11:59 AM
storminasu Re: ActiveX checkbox to... 04-18-2019, 12:06 PM
Winon Re: ActiveX checkbox to... 04-18-2019, 12:20 PM
storminasu Re: ActiveX checkbox to... 04-18-2019, 02:46 PM
storminasu Re: ActiveX checkbox to... 04-18-2019, 12:33 PM
  1. #1
    Registered User
    Join Date
    03-13-2013
    Location
    North Carolin
    MS-Off Ver
    Excel 2013
    Posts
    5

    ActiveX checkbox to unlock cell and set allow override

    Hello everyone,
    I have a worksheet that has a formula in K9, that is a looking up an account number (in k5) to check membership status. I'd like to have k9 locked and protected unless the override checkbox (activeX) is selected. If it's selected, I'd like the worksheet to unprotect, unlock the cell, then reprotect. After it's protected again with the check box selected, the box will allow an override value of Yes or No only. If the override checkbox is unselected subsequently (false), the workbook will unprotect, lock cell again, replace value with formula, then protect.

    With the code below (I am very new to VBA with no previous coding experience), I keep getting an "End With" error.

    Any help is very much appreciated. Thank you all!

    Private Sub WineClubOverride_Click()
    
    Dim rMyRng As Range
     With ActiveSheet.ActiveWorkSheet.Unprotect
    Set rMyRng = Range("k9")
    
    
    Range("K9").Locked = False
    rMyRng.Formula = "=IFERROR(IF(VLOOKUP(K5,'Wine Club List'!$K$8:$L$200,2,FALSE)<>0,""Yes"",""No""),""No"")"
    Range("K9").Locked = True
    With ActiveSheet.ActiveWorkSheet.Protect
    End With
    
    
    If WineClubOverride.Value = True Then ActiveWorkSheet.Unprotect
    If WineClubOverride.Value = True Then Selection.Locked = False
    
    
    If WineClubOverride.Value = True Then rMyRng.Value = rMyRng.Value
    If WineClubOverride.Value = True Then ActiveWorkSheet.Protect
    End With
    
    
    End Sub

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: ActiveX checkbox to unlock cell and set allow override

    You could remove all your With and End With lines as they do not serve any purpose.

  3. #3
    Registered User
    Join Date
    03-13-2013
    Location
    North Carolin
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: ActiveX checkbox to unlock cell and set allow override

    Thank you very much for your quick reply.

    After removal:
    Private Sub WineClubOverride_Click()
    
    Dim rMyRng As Range
    ActiveSheet.ActiveWorkSheet.Unprotect
    Set rMyRng = Range("k9")
    
    Range("K9").Locked = False
    rMyRng.Formula = "=IFERROR(IF(VLOOKUP(K5,'Wine Club List'!$K$8:$L$200,2,FALSE)<>0,""Yes"",""No""),""No"")"
    Range("K9").Locked = True
    ActiveSheet.ActiveWorkSheet.Protect
    
    
    If WineClubOverride.Value = True Then ActiveWorkSheet.Unprotect
    If WineClubOverride.Value = True Then Selection.Locked = False
    
    If WineClubOverride.Value = True Then rMyRng.Value = rMyRng.Value
    If WineClubOverride.Value = True Then ActiveWorkSheet.Protect
    
    End Sub
    I get the following error:
    Attachment 620692
    Last edited by storminasu; 04-18-2019 at 11:43 AM. Reason: Forgot to be appreciative

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: ActiveX checkbox to unlock cell and set allow override

    Unfortunately, I can't access the picture - perhaps you could post the text?

    I'm a bit confused by what you're trying to do.

    If the checkbox is ticked, do you just want the formula removed from K9?

    If the checkbox is not ticked, you want to add the formula?

    Have I understood correctly?

    (Btw ActiveWorksheet is not correct syntax.)

  5. #5
    Registered User
    Join Date
    03-13-2013
    Location
    North Carolin
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: ActiveX checkbox to unlock cell and set allow override

    In my original post I mentioned what I was trying to do and the fact I was very new to this, so is there anything in particular that I didn't make clear enough or I need to elaborate on? I tried to spell out my thought process there, but hopefully the summary below is more succinct

    I want a protected workbook, with the option to override a cell that starts out with a locked formula, but if the checkbox is selected, the worksheet unprotects, unlocks cell and allows a value to be entered. If the checkbox is set to false afterwards, the process reverses, ending with a protected and locked formula.

    I had the override portion working, but when I tried to add protection, it began to give errors.

    After removing the End withs, etc. in your first post, the error was as follows:
    Run-time error '438':
    Object doesn't support this property or method

  6. #6
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: ActiveX checkbox to unlock cell and set allow override

    Hello storminasu,

    If everything fails, check the manual!

    Please attach a sample workbook (not a picture or pasted copy).
    Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  7. #7
    Registered User
    Join Date
    03-13-2013
    Location
    North Carolin
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: ActiveX checkbox to unlock cell and set allow override

    Quote Originally Posted by Winon View Post
    Hello storminasu,

    If everything fails, check the manual!

    Please attach a sample workbook (not a picture or pasted copy).
    Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

    Regards.
    Did the attachment actually work?

    Did it clear up my question?

  8. #8
    Registered User
    Join Date
    03-13-2013
    Location
    North Carolin
    MS-Off Ver
    Excel 2013
    Posts
    5

    Re: ActiveX checkbox to unlock cell and set allow override

    Ok, thank you. I appreciate both of you helping very much. I have attached a workbook now, I hope it helps.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Need to Link Cell to ActiveX Checkbox
    By Miguelhn94 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-29-2019, 10:47 PM
  2. Replies: 13
    Last Post: 07-28-2017, 07:58 AM
  3. ActiveX checkbox to insert a cell from a different workbook
    By whytewolves in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 10-24-2015, 07:07 PM
  4. [SOLVED] Linked Cell for ActiveX Checkbox via VBA
    By Papa Newch in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-05-2014, 06:52 PM
  5. [SOLVED] Forms Control checkbox and code to unlock a cell
    By JimDandy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-21-2013, 04:46 PM
  6. Unlock a cell based on checkbox value in another cell
    By EJohnson79 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-05-2013, 01:10 PM
  7. Override the data in the cell when checkbox is clicked
    By gsweta in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-04-2009, 10:57 AM

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