+ Reply to Thread
Results 1 to 6 of 6

Clearing values in a dependent data validation list

Hybrid View

  1. #1
    Registered User
    Join Date
    01-30-2010
    Location
    World
    MS-Off Ver
    Excel 2007
    Posts
    20

    Clearing values in a dependent data validation list

    Hi,

    I have set up a dependent data validation list whereby Column A = Departments and Column B = Staff Names. The values available in Column B are dependent on what is selected in Column A.

    If a value in Column A is deleted, is there a way of automatically clearing the corresponding Column B value? I am using approximately 1000 cells in each column.

    Thanks for your help!
    Last edited by PHUAG; 03-24-2010 at 06:45 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,808

    Re: Clearing values in a dependent data validation list

    At first glance I would say the easiest way to do this is with VBA.

    Are you saying that you have one set of data in Column A that is a validation list, or that the cells in A have data validation that use a list defined somewhere else?

    Same kind of question for column B. How are you managing the change in data validation choices for staff based on the selection of department?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Clearing values in a dependent data validation list

    You would need VBA to do this. Right click on your worksheet Tab and "View Code" Then paste in this code.
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 1 Then     'where 1 is your column, in this case A (1)
    Target.Offset(0, 1) = ""
    
    End If
    End Sub
    Does this work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Clearing values in a dependent data validation list

    VBA is an option and probably what I would use. But you can do something "almost" as good with conditional formatting. You can use CF to check if the value in column B matches to the named range in column A, and if it is NOT a match any longer, discolor the cell in a harsh way.

    Here's a sample sheet showing what I mean:

    DependentLists3.xls
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Registered User
    Join Date
    01-30-2010
    Location
    World
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Clearing values in a dependent data validation list

    Thanks for all your suggestions. I think I would prefer to use VBA rather than conditional formatting. The code provided by Chemist B doesn't work and I don't understand what I'm doing wrong. I have attached part of my worksheet so you can see what I'm trying to do. Thanks
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    01-30-2010
    Location
    World
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Clearing values in a dependent data validation list

    I've tried it again & it seems to be working now. Thanks once again.

+ 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