+ Reply to Thread
Results 1 to 11 of 11

Data Validation,Restrict Cell Input.

  1. #1
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Data Validation,Restrict Cell Input.

    Hey guys,

    I have a situation where I need to limit user input. I can't use excels data validation as it is rendered moot when copied over.

    I was thinking of an event handler macro that would only allow the criteria that I need to entered. Anything else would bring up an error message and say try again.
    Eg, say I want only the characters A, B, C, D, E, F ,G to be entered into a designated range A1:G5 and only 1 character to a cell. If someone enters anything other than these characters then the error appears.
    Eg A is OK, But AB is not , B is OK, 1 is not ,Y is not.

    I am not sure if this can be done, but I thought I would ask anyway.

    Cheers
    Last edited by JapanDave; 11-27-2011 at 11:05 PM.

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Data Validation,Restrict Cell Input.

    Data Validation would do that.
    What are the details that render it "moot"?
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Data Validation,Restrict Cell Input.

    There is no need for VBA.

    Highlight Range A1:G5, go to Data > Data Validation > Custom and enter the formula

    =AND(OR(A1="A",A1="B",A1="C",A1="D"),LEN(A1)=1)

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Data Validation,Restrict Cell Input.

    Another Validation method would be to use List style validation with the source
    A,B,C,D,E,F,G

  5. #5
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Data Validation,Restrict Cell Input.

    Mike's method is a lot better than mine

  6. #6
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Data Validation,Restrict Cell Input.

    Hi Mike,

    If someone copies a cell from somewhere else that does not have data validation and pastes it over the data validation cell, it removes the data validation criteria.

  7. #7
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Data Validation,Restrict Cell Input.

    Insert the code to the worksheet module

    Please Login or Register  to view this content.
    Last edited by JieJenn; 11-27-2011 at 10:06 PM.

  8. #8
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Data Validation,Restrict Cell Input.

    Thanks guys,

  9. #9
    Valued Forum Contributor
    Join Date
    05-19-2010
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2010
    Posts
    391

    Re: Data Validation,Restrict Cell Input.

    JieJenn can this code be used in a name range for data validation

  10. #10
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Data Validation,Restrict Cell Input.

    Hey Grizzly,

    It can be, just amend the code to say what your named range is.

    Please Login or Register  to view this content.

  11. #11
    Valued Forum Contributor
    Join Date
    05-19-2010
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2010
    Posts
    391

    Re: Data Validation,Restrict Cell Input.

    when I changed range to ("Mylist") it allowed paste in cell possibly not in correct location

+ 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