A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Hi,
This conditional formatting formula works
=NOT(ISERROR(REGEXEXTRACT(A2,"\d{4}")))
Hope this helps.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I wish to create a conditional formatting rule to highlight any cell that has four digits together - like a Year but not a date format;
so to highlight the cell with "2026 Winter Olympics" where the year could be any year (not just 2026).
Any help will be appreciated
Thanks
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Hi,
This conditional formatting formula works
=NOT(ISERROR(REGEXEXTRACT(A2,"\d{4}")))
Hope this helps.
any cell that has four digits together - like a Year
For the poster, you have an excellent solution, but functions like NOT, and ISERROR would not be necessary if looking for 4 digit numbers as in column C, unlike that of column A.
Hello DeanH,
Thank you for posting your question in the Microsoft Q&A forum!
I understand that you are having issue with conditional formatting in Excel. I truly understand how you feel. Let me assist you go through this situation.
With your situation, I suggest you try this:
Works for: 2026 Winter Olympics. No helper cells
Finds any 4‑digit number inside text. Compatible with older Excel
Important:
I hope this will help with your situation. Please feel free to reach back if you have further update or more questions.
Best Regards,
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment”.
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.
To create a conditional formatting rule in Excel that highlights any cell containing a four-digit number (like a year), you can use a formula-based approach. Here’s how you can set it up:
=AND(ISNUMBER(VALUE(MID(A1,SEARCH("[0-9][0-9][0-9][0-9]",A1),4))), LEN(A1) > 4)
Replace A1 with the first cell in your selected range.This formula checks for a four-digit sequence within the text and highlights the cell if it finds one. The SEARCH function looks for a four-digit number, and ISNUMBER checks if the result is a number.
References: