+ Reply to Thread
Results 1 to 7 of 7

Worksheet_change event add / remove validation

  1. #1
    Forum Contributor
    Join Date
    06-15-2011
    Location
    Chester, England
    MS-Off Ver
    Excel 2013
    Posts
    117

    Worksheet_change event add / remove validation

    In the attached, if a user puts a number in the columns 'Sick', or 'Susp'd / Leaver', validation dropdown lists are added to the corresponding cell in the 'Comments' column.

    If entries are deleted, the validation is also deleted from the relevant comments column (usually).

    This works to a point, but if you enter a value without hitting enter (e.g. Press tab or a cursor other than down, or click on a different cell), the validation does not get applied.

    Also, if you delete entries one at a time from the bottom of several consecutive ones, the delete validation does not work.

    The problems arise when testing whether the Target is blank - it will be in a different position depending on how the data has been entered.

    Thanks in advance for any help you can offer - it will be greatly appreciated.
    Attached Files Attached Files

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

    Re: Worksheet_change event add / remove validation

    1) Remove the worksheet_change event for a moment from that sheet.

    2) Put the number 1 in F9 temporarily

    3) Select AJ9:AJ101

    3) Apply this DV setting manually:

    Allow: List
    Source: =IF(F9>0,sick,IF(J9>0,Leaver))

    4) Now look at the drop down in AJ9, it is for the SICK option.

    5) Remove the 1 in F9 and put a 1 in J9.... now look?

    6) Now remove the 1 altogether and look again...

    No VBA needed for this.
    _________________
    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!)

  3. #3
    Forum Contributor
    Join Date
    06-15-2011
    Location
    Chester, England
    MS-Off Ver
    Excel 2013
    Posts
    117

    Re: Worksheet_change event add / remove validation

    Thanks for your reply.

    I was hoping to avoid this route because the column also needs to allow free text - is there a way to do that as well?

  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: Worksheet_change event add / remove validation

    In the DV settings, go to the ALERT tab and turn them off. This will allow you to free text as well.

  5. #5
    Forum Contributor
    Join Date
    06-15-2011
    Location
    Chester, England
    MS-Off Ver
    Excel 2013
    Posts
    117

    Re: Worksheet_change event add / remove validation

    Nice one - so simple!

    It won't let me tip your scales again (not that need more rep points!), so thanks again.

    One more thing, is there a way to use a list on a different sheet? It seems that I can't use this method if the list is on another sheet.
    Last edited by tone640; 03-05-2012 at 09:44 AM.

  6. #6
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Worksheet_change event add / remove validation

    As long as you use a named range, not a range address, it can be on any sheet.
    Good luck.

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

    Re: Worksheet_change event add / remove validation

    What OnGotoError0, said... named ranges make DV lists work on any sheet.

    If that takes care of your original need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

+ 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