Looking for data validation formula help

Courtney K 20 Reputation points
2026-07-09T17:04:09.48+00:00

I would like to setup a data validation to check that the entered data is exactly 7 digits long, AND starts with 8. Please and thank you!

Microsoft 365 and Office | Excel | For business | Windows
0 comments No comments

Answer accepted by question author
Hendrix-C 20,005 Reputation points Microsoft External Staff Moderator
2026-07-09T17:32:18.33+00:00

Hi Courtney,

For your concern, you can use this setup:

  • Select the range you want to check. As an example, I select range A1:A10
  • Go to Data > Data Validation > under Allow, choose Custom from the drop-down menu
  • Paste this formula =AND(LEN(A1)=7,LEFT(A1,1)="8",SUMPRODUCT(--ISNUMBER(--MID(A1,ROW($1:$7),1)))=7) (Note: change the cell based on the start cell of your select range. For example: if choosing B5:B20, replace A1 with B5)

User's image

  • If you want an error message when inputting wrong value, you can go to Error Alert and set up the error message as you prefer. After finished, press OK. You can use or adapt my message as well:

User's image

As a demonstration on how it will work:

User's image

Please try these steps and let me know whether it meets your need. If not, please feel free to reach out again in the comments on this post. I'm happy to assist you further

Thank you for your understanding and cooperation. I'm looking forward to your reply.


If the answer is helpful, please click "Yes" and kindly upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.