+ Reply to Thread
Results 1 to 15 of 15

Creating a self updating Data Validation List

  1. #1
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Creating a self updating Data Validation List

    I saw something like this described in an EF thread.
    I'm not sure if it was working or not.
    Anyway, I thought I'd have a go at reproducing it ...

    The code is self contained in this WS Change Event

    Basically, it has a DV List with an option to add new entries


    Please Login or Register  to view this content.

    Seems to cope well with alphabetic and numeric entries, although "dates" go in as text looking like a date.

    Enjoy. If you break it, let me know.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Creating a self updating Data Validation List

    Slightly improved version with worked example.


    Please Login or Register  to view this content.


    Regards, TMS
    Last edited by TMS; 09-11-2012 at 07:09 AM.

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Creating a self updating Data Validation List

    nice idea. just as an alternative here is a class-based version. haven't done a lot of testing but it seems ok. you could use a collection to store the monitors and monitor several ranges in the workbook.
    Attached Files Attached Files
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Creating a self updating Data Validation List

    Thanks to JP for his alternative approach (and his advice on content )

    Version 3 ... well, version 2 of my code but JP has bagged V2

    This sets the Target value to the newly input DV entry rather than make it a two stage process.

    If [New Entry] is selected and then an existing value input, nothing changes.

    Please Login or Register  to view this content.

    Regards, TMS
    Attached Files Attached Files

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Creating a self updating Data Validation List

    @JP: thanks for the alternative approach. It's good to have a practical working example of a class module

    Can I ask, why do you allow a target range and loop through it? I can't see how you can make use of that feature. I tend to limit a change event to a single cell and exit if a multi cell range is selected.

    Cheers, TMS

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Creating a self updating Data Validation List

    why not? :-)
    I try to never limit change events to one cell handling because there are numerous situations where a user might reasonably alter more than one cell at a time and I want it handled (copy/paste or ctrl+enter for instance) and not just ignored
    I admit it's unlikely for this scenario but you never know

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Creating a self updating Data Validation List

    @JP: fair enough

  8. #8
    Forum Contributor
    Join Date
    10-16-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    257

    Re: Creating a self updating Data Validation List

    I can't get this to work, I am fairly new to this sort of thing though.
    I've copied and pasted the code.
    Renamed the sheet to Input
    Created the headings
    made the list from D2 1-9.
    Then in A2 when I do Data validation then put =DV_List it comes up with Unknown source.
    I was looking forward to using this on my project, then was thinking would it be just as good if there was an auto V-Lookup when something is added in the columns also!

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Creating a self updating Data Validation List

    Where have you pasted the code? It's a worksheet change event so it has to go in the sheet where you want to have the Data Validation.

    In this example, both the Data Validation and the Data Validation List are on the same sheet ... that was really just for the convenience of the demonstration.

    Did you set up the dynamic named range?

    DV_List: =Input!$D$2:INDEX(Input!$D:$D,COUNTA(Input!$D:$D))


    Regards, TMS

  10. #10
    Forum Contributor
    Join Date
    10-16-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    257

    Re: Creating a self updating Data Validation List

    Yes its on the same work sheet (named Input) But Dynamic named range??????????? have not got a clue! I'm down the library tomorrow to get a book on excel and get up to speed!

    Yes both the drop down list and data list was on the same page just like the layout you had, as the sheet I have made HAS to have them both on the same sheet as it runs on the older version of excel in work.

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Creating a self updating Data Validation List

    Select the Formula Ribbon, click on Name Manager, click on New

    Name: DV_List:
    Refers to: =Input!$D$2:INDEX(Input!$D:$D,COUNTA(Input!$D:$D))

    PM me your email address and/or a sample workbook (.xls) if you want it to be compatible.


    Regards, TMS

  12. #12
    Forum Contributor
    Join Date
    10-16-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    257

    Re: Creating a self updating Data Validation List

    I'll have a play when I'm back on the PC tomorrow, I have 3 groups of drop downs repeated 3-4 times across 4 sheets.
    Do you think it would be possible for an auto update for a vlookup?

  13. #13
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Creating a self updating Data Validation List

    Do you think it would be possible for an auto update for a vlookup?

    I have no idea what that means

    Regards, TMS

  14. #14
    Forum Contributor
    Join Date
    10-16-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    257

    Re: Creating a self updating Data Validation List

    Sorry, what I'm using is a validation list which i'm hoping to include what you have here.
    But also in my book, there is a sheet with the same list of products with prices next to it which uses a V lookup to find the product and then bring back the cost of that product.

    When I add products to the validation list and to the price list, I have to change the lists accordingly. So seeing what you have done here, would it be possible to create a macro that detects this list and extends automatically when more products/prices are added to the cells that contain the lookup formula?

  15. #15
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Creating a self updating Data Validation List

    You should just make the product/price list a dynamic named range.

    You're really going to have to post a sample workbook to get a definitive answer. It's not difficult once you know how but it's going to take forever if we keep playing bounce.

    Regards, TMS

+ 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