Excel : Data Validation, how to force the user to enter a string that is 2 char long?

后端 未结 6 1029
梦谈多话
梦谈多话 2021-01-14 23:56

I would like to add some data validation on a cell in the latest Excel. I would like to force the user to enter a string that is two-char long, with the first char a digit,

6条回答
  •  孤城傲影
    2021-01-15 00:23

    For the first part you will need a formula such as this for Data Validation

    =AND(LEN(A1)=2,ISNUMBER(VALUE(LEFT(A1,1))),CODE(RIGHT(LOWER(A1),1))>=97,CODE(RIGHT(LOWER(A1),1))<=122)

    This part runs a case insensitive test for a letter between a to z CODE(RIGHT(LOWER(A1),1))>=97,CODE(RIGHT(LOWER(A1),1))<=122)

    ISTEXT(RIGHT(A1,1))) will validate characters other than a-z to being text as it is a string test, even numbers will be allowed. This is why the VALUE portion of (VALUE(LEFT(A1,1))) is needed to force a numeric evaluation of the first position in the string

提交回复
热议问题