+ Reply to Thread
Results 1 to 10 of 10

Adding Custom Data Validation when a cell contains a Drop Down List.

  1. #1
    Registered User
    Join Date
    04-06-2020
    Location
    Minnesota
    MS-Off Ver
    2013
    Posts
    15

    Question Adding Custom Data Validation when a cell contains a Drop Down List.

    Hello all,

    My problem - I would like to Lock a cell dependent on whether or not another cell has data in it. Previously mentioned cells already contain Data Validation (Drop Down List). Basically if you pick from this list, I don't want you to pick from the list within that cell. What I mean by "lock" is, I would like to prevent a user from entering data via a stop error message. First problem is the cells already utilize Data Validation. I thought my work around would be to reference that cell to another and apply Data Validation to that cell. When I try this in Custom Data Validation using (example, =cell="") it will not recognize the value in the cell because it is sourced from a list. I've attached an example problem to show what I am trying to do. For a visual I have also added Conditional formatting to color fill the cell if the other is being used. Essentially if the cell has color fill in it , then the user is also stopped from picking from the list in that cell. Thank you for any help.
    Attached Files Attached Files
    Last edited by mgselin; 04-07-2020 at 08:10 AM.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Adding Custom Data Validation when a cell contains a Drop Down List.

    Hi, welcome to the forum.
    Maybe I missundertood your question/request, but data validation is just that, only valid data (from the drop-down list) is permitted, the error message shows that en the focus is set to the cell.
    Nothing else can be entered.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Adding Custom Data Validation when a cell contains a Drop Down List.

    Think I see got it. You only want to permit or List A or List B
    To achieve this I think only VBA will solve it for you, you will have to add macros and code them accordingly

  4. #4
    Registered User
    Join Date
    04-06-2020
    Location
    Minnesota
    MS-Off Ver
    2013
    Posts
    15

    Re: Adding Custom Data Validation when a cell contains a Drop Down List.

    Keebellah,

    Using a drop down list I am already restricting the user. In addition I want to restrict the user from entering data in an adjacent cell if you picked data in the original cell.

  5. #5
    Registered User
    Join Date
    04-06-2020
    Location
    Minnesota
    MS-Off Ver
    2013
    Posts
    15

    Re: Adding Custom Data Validation when a cell contains a Drop Down List.

    That was my fear. I have zero experience in VBA. I am kinda lying. I can navigate and I get the premise of writing macros in VBA. I just don't know the process.

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Adding Custom Data Validation when a cell contains a Drop Down List.

    Well, now's the best time to start learning.
    VBA is very simple and straightforward.
    The problem is that of course we can offer a helping hand but in the end it's you that has to maintain it an understand it.
    There a loads of free tutorials and the most efficient way is to follow these and start on your own from scratch.
    We all started with recording a macro and then looking at the code and see what it did.
    Then... imagination is the limit, all you need (plenty off) is time and much more of that.
    Respecting the syntax rules it's like writing a story.
    If I do this and the value of cell A is equals to this then cell b will have to be that else if this etc. etc . etc.

    The you 'translate this story to VBA

    Please Login or Register  to view this content.
    I'll take a look at your file and see if I can put you on the right track but ... take the time to lear, it's fun and once you get the hang of it, it's addictive

  7. #7
    Registered User
    Join Date
    04-06-2020
    Location
    Minnesota
    MS-Off Ver
    2013
    Posts
    15

    Re: Adding Custom Data Validation when a cell contains a Drop Down List.

    I appreciate your help.
    I recently ran into this problem last Thursday and exhausted all of my options up to VBA.
    This is definitely an opportunity to learn something new.

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Adding Custom Data Validation when a cell contains a Drop Down List.

    This is a little more than basic VBA but for starters.
    First, please avoid Merged cells like you did, that's a P in the A when it comes to selecting cells using VBA.
    I reduced it to a single cells for now.
    To make it work cells have to be locked or unlocked and the only way locked and Unlocked works for selections is ia a worksheet is protected.
    I protected the worksheet (no password) but only unlocked cells can be selected.
    List A and List B are unlocked, so you can select an item from either dropdown list, if you select A then B is locked (and black fill like you had)
    Clear the contents in the one selected and both are free to access again.
    I have no idea what you want to achieve with this but hope it gives you an idea how it works and, once again, VBA is not that complicated but there are some things that exceed the beginner's steps

    For starters, a link to check out, has nice samples and explains things a little
    http://www.cpearson.com/Excel/vbe.aspx
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    04-06-2020
    Location
    Minnesota
    MS-Off Ver
    2013
    Posts
    15

    Re: Adding Custom Data Validation when a cell contains a Drop Down List.

    Thank you for all of your help.
    It is nice to see an example of a macro that attempts to do what I am looking for.
    Though this doesn't exactly solve my problem, it does show me that learning VBA is necessary.
    Thank you for providing me a link leading me in a direction to start learning.
    I'll use this as a starting point and develop from there.
    Thank you again.

  10. #10
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Adding Custom Data Validation when a cell contains a Drop Down List.

    You're welcome, I'm convinced that once you start you'll love it.
    It's a great tool to enhance the use of Excel

+ 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] VBScript Adding Data Validation List to a Cell
    By mowens74 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-16-2022, 03:17 AM
  2. [SOLVED] using a data validation drop down list AND an IF formula in the same cell
    By bite_tony in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-23-2021, 02:59 AM
  3. adding custom fill color to drop down list
    By InvGrp2 in forum Excel General
    Replies: 2
    Last Post: 06-28-2017, 11:49 PM
  4. [SOLVED] Data validation, list and custom in one cell
    By Bobz1983 in forum Excel General
    Replies: 4
    Last Post: 08-11-2014, 08:04 PM
  5. Drop-Down List with List and Custom Data Validation
    By KyleElliott in forum Excel General
    Replies: 4
    Last Post: 05-03-2014, 08:31 AM
  6. Data Validation List and Custom formula in 1 cell
    By murugavelmsc in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-11-2013, 02:50 AM
  7. Replies: 2
    Last Post: 05-12-2011, 09:23 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