+ Reply to Thread
Results 1 to 5 of 5

Checkbox triggering data validation failed

  1. #1
    Forum Contributor
    Join Date
    06-19-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Office365
    Posts
    276

    Checkbox triggering data validation failed

    Hello,

    I have a checkbox that controls whether or not a bunch of cells should have data validation applied. there is a workbook.open event that applies data validation to J18:N23 upon open
    Worksheets("Model").Range("J18:N23").Validation.Delete didn't work. when I checked the box, the validation still exists in those cells. can someone please let me know how to make it work?

    PHP Code: 
    Private Sub Revenue_Click()
    Dim sh As Worksheet

    Set sh 
    Worksheets("Scenarios")
    If 
    Revenue.Value True Then sh.Range("B12") = "Revenue"
    [FONT=Arial Black]Worksheets("Model").Range("J18:N23").Validation.Delete[/FONT]
    If 
    Revenue.Value False Then sh.Range("B12") = ""
    Worksheets("Model").Range("J18:N23").Validation.Add Type:=xlValidateListAlertStyle:=xlValidAlertStop_
    Formula1
    :="% Growth from Prev. Year,Source Company,Scenario"
    End Sub 
    thanks so much
    Last edited by lynnsong986; 11-02-2019 at 08:58 PM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Checkbox triggering data validation failed

    I'm not sure I follow what you are describing. Your code deletes validation (blue) and then adds it back (red).

    Please Login or Register  to view this content.
    '
    Last edited by AlphaFrog; 11-02-2019 at 09:43 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    06-19-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Office365
    Posts
    276

    Re: Checkbox triggering data validation failed

    What I was trying to do is that if the checkbox is checked, which returns "True", then remove the validation from those cells; if the checkbox is unchecked, which returns "False", then add the validations. I guess I must have some logic errors in this so it didn't work. I hope I made it clear? I rarely use these controls, so please help!

    Thanks so much for your time!

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Checkbox triggering data validation failed

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    06-19-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Office365
    Posts
    276

    Re: Checkbox triggering data validation failed

    OMG, thank you so so so so so much!!! AlphaFrog you saved my day!! I'm been scratching my head for the last hour, now I can go enjoy my weekend!! thanks you are awesome!!

+ 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] Copying range not triggering data validation list rule
    By jaryszek in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-16-2019, 10:33 AM
  2. data validation failed on time field
    By only_lonely in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-18-2018, 10:00 AM
  3. If checkbox checked then data validation
    By mdek in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-04-2016, 11:21 AM
  4. Triggering Macros from Validation List
    By Pratster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-06-2010, 10:16 PM
  5. VBA for data validation --> Method 'Add' of object 'Validation' failed
    By bagullo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-10-2010, 06:18 AM
  6. [SOLVED] Validation not triggering Change event in Excel XP
    By Jeffrey in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2006, 11:40 PM
  7. [SOLVED] Validation not triggering Change event in Excel XP
    By Jeffrey in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-07-2006, 10:10 PM

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