+ Reply to Thread
Results 1 to 7 of 7

Validation value cell update logic

  1. #1
    Registered User
    Join Date
    01-07-2015
    Location
    Leicester, England
    MS-Off Ver
    2013
    Posts
    3

    Validation value cell update logic

    Hi

    In an excel sheet I have built some dynamic selection lists where the tier1 selection drives the tier2 & tier 3 available lists (tier 3 is a static list that has the same 7 entries for all tier 2 responses, which are also valid for all tier1 responses). At the moment only valid values for the tier2 field appear when tier1 is populated from a list.

    I'm now trying to complete add some validation logic & automated corrections to update the sheet (tier2 & tier3 field) if and when the validation.value for tier2 is False. Is there a way to use the validation.value check to determine/select a cell and then update the tier3 value

    Code I've been playing with attached below, the Active.Cell select statement picks the first cell in the defined range, not the cell detected as invalid, is there a way to move the select to the invalid data cell and loop down the range clearing all related tier3 values before clearing all invalid tier2 values

    Sub DeleteInvalidData()
    'Columns("M:M").Select
    Range("M1:O20").Select
    Dim C As Range
    For Each C In Selection
    'changes column 2 row 1 only
    If C.Validation.Value = False Then ActiveCell.Select
    ActiveCell.Offset(0, 2).Value = "Choose..."
    'removes invalid entry values from range
    If C.Validation.Value = False Then C.Value = ""
    Next
    End Sub

    Thanks
    Last edited by shelby_335; 01-08-2015 at 12:03 PM.

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Validation value cell update logic

    This is your question
    Is there a way to use the validation.value check to determine/select a cell and then update the tier3 value
    The answer is yes, but explaining the answer is not that easy. Submit a copy of your workbook so we can show you/give you code to do what you need to do.

  3. #3
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Validation value cell update logic

    If I get it correctly C is the cell being tested? If so, then instead of
    Please Login or Register  to view this content.
    try
    Please Login or Register  to view this content.
    This will activate C rather than selecting the active cell, which is the cell active before the macro runs. (Or last activated cell)
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  4. #4
    Registered User
    Join Date
    01-07-2015
    Location
    Leicester, England
    MS-Off Ver
    2013
    Posts
    3

    Re: Validation value cell update logic

    VBA Coding Query.xlsm

    Thanks - I had tried to attach the file but without success will try again.

    I tried the logic suggested by Arkadi however it seems that the C.Validation.Value check does not trigger a cell selection and the initial range selection is maintained.
    Last edited by shelby_335; 01-08-2015 at 02:27 PM.

  5. #5
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Validation value cell update logic

    Note: This is not possible
    Please Login or Register  to view this content.
    Try this
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    01-07-2015
    Location
    Leicester, England
    MS-Off Ver
    2013
    Posts
    3

    Re: Validation value cell update logic

    Thanks for the advice on the not possible elements, I'm a VBA newbie/numpty so there's a few bits of code I've played with whilst trying to get this to work

    I've tried porting the code into the sheet VBA code and am not able to make it work to help me understand let me paraphrase on the code you have provided

    The first element of the code looks at the range in column A and if the field is blank then it deletes the target value in column C, however when I run the code I get a number of errors "Run-time error '1004' when column A is blank or set to "Choose..." from the row .Add Type

    Attached v2 of the XLS with the code you supplied included

    I'm not I understand sure how the code is supposed to work to check that the values in column C are valid compared to the value specified in column A and then reset column C & E to the value "Choose..." if the not valid state is detectedVBA Coding Query v2.xlsm
    Last edited by shelby_335; 01-08-2015 at 07:08 PM.

  7. #7
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Validation value cell update logic

    It works as follows:

    1. You select a value from the data validation in column A.
    2. That selection trigger the macro to populate the data validation in column C based upon the Named Ranges that you set up.
    3. Here is the rub. I just noticed that your named ranges don't exactly match the values in the data validation options in column A. You need to change this.

    I have amended to code to bypass if you delete the value in column A or change it to "Choose". You need to amend your named ranges to exactly match the selection in column A.
    There are other ways to do it but this is quick and easy.

    Please Login or Register  to view this content.

+ 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. Update certain Cell based on clicking one data validation box
    By bcn1988 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-20-2012, 02:37 PM
  2. [SOLVED] Cell Update on Data Validation Selection
    By HangMan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-12-2012, 03:32 PM
  3. Excel 2007 : Update links logic loop error
    By edmdas in forum Excel General
    Replies: 0
    Last Post: 02-02-2010, 01:24 PM
  4. Update a validation list based on value of another cell
    By JDM11808 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-05-2009, 07:53 PM
  5. Update Validation List from cell
    By pkeegs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-21-2006, 11:20 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