+ Reply to Thread
Results 1 to 4 of 4

Data Validation using VBA code

  1. #1
    Registered User
    Join Date
    12-29-2011
    Location
    San Diego, Ca.
    MS-Off Ver
    Excel 2007
    Posts
    60

    Data Validation using VBA code

    The code below generates a dynamic drop down list in Excel 2007. For simplicity, the source list is in the WS "_BfrBNam" and consists of 3 choices (A, B, C). The drop down list appears on the WS "Actual" in cells B3-B1500. All works well except if an entry in cells B3-B1500 is NOT A,B or C there is no error message generated. This can be fixed by unchecking the Ignore Blank on the Data Tools tab, Data Validation, Settings. The question is how can the code below be modified to uncheck this box which appears to be normally checked.

    I hope this is clear.

    #
    Dim rng As Range
    Set rng = Sheets("Actual").Range("B3:B1500") ' This is the validation range.
    With rng.Validation
    .Delete
    .Add Type:=xlValidateList, AlertStyle:=xlValidAlertWarning, _
    Operator:=xlBetween, Formula1:="=_BfrBNam" 'This is the list containing A, B or C
    End With

    #

  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,502

    Re: Data Validation using VBA code

    Try:

    Please Login or Register  to view this content.
    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


  3. #3
    Registered User
    Join Date
    12-29-2011
    Location
    San Diego, Ca.
    MS-Off Ver
    Excel 2007
    Posts
    60

    Re: Data Validation using VBA code

    Yep, that worked. After I saw your corrections it became obvious. Thanks.

  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,502

    Re: Data Validation using VBA code

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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] VBA Code to pull data from cell that has data validation
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-16-2016, 11:02 PM
  2. Data Validation code too long
    By blacky1 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-21-2011, 04:00 AM
  3. VBA code for Data Validation
    By Zimmerman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-02-2010, 12:22 PM
  4. Data Validation=> List=> code for quickly finding data
    By goodgirl1982 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-05-2007, 03:39 AM
  5. Data Validation code
    By carsto in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-05-2007, 06:50 PM
  6. [SOLVED] Data validation through code
    By Diva in forum Excel General
    Replies: 4
    Last Post: 05-11-2006, 08:50 AM
  7. [SOLVED] Data Validation in code...
    By Theresa Smallwood in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-01-2005, 05:05 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