+ Reply to Thread
Results 1 to 9 of 9

Workaround for Data Validation (List) limitation

Hybrid View

  1. #1
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Workaround for Data Validation (List) limitation

    Hi,

    I programatically add List Data Validation to a range via vba. Works fine until you close and open the workbook. An error appears stating that there are unreadable areas in the workbook and whether I would like to attempt to still read the workbook. When I say yes, then it informs that it removed the data validations.

    When I put the list in another range and reference it, no problems.

    The list is 50 items and growing...

    Any thoughts on a workaround so that I can store the full list in vba instead of in a range on a worksheet.

    Thanks.

    abousetta
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

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

    Re: Workaround for Data Validation (List) limitation

    how long is the list (# of characters)?
    Josie

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

  3. #3
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Workaround for Data Validation (List) limitation

    1310 characters... too long?

    abousetta

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

    Re: Workaround for Data Validation (List) limitation

    much! 255 is the legal limit http://support.microsoft.com/kb/299490

  5. #5
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Workaround for Data Validation (List) limitation

    OK... thanks... I guess I will have to leave them in the Excel sheet and reference the range because that oddly seems to work.

    abousetta

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

    Re: Workaround for Data Validation (List) limitation

    a range reference is likely to be less than 255 characters so it works (similar to the issue with assigning literal values to a chart series formula versus using a range)

  7. #7
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Workaround for Data Validation (List) limitation

    Hi JP,

    A workbook is worth a million words... or bytes... or something...

    Two subs. First runs validation with the full list hard-coded into the vba code. The second runs validation with a list entered as a range from Excel.

    If you run the first sub you shouldn't get any errors and validation is added to Range("A1"). Save the workbook and reopen... error... when you attempt to recover the workbook, Excel should delete the validation.

    Now run the second sub which gets the list from a range. Same as before, no errors and validation is now available in Range("B1"). Save the workbook and reopen... no errors...

    abousetta
    Attached Files Attached Files

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

    Re: Workaround for Data Validation (List) limitation

    yes-it violates the rules. probably a bug that it lets you do it at all

  9. #9
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Workaround for Data Validation (List) limitation

    I guess some rules are made to be broken

+ 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