Hi - Dave here.

Happy Friday!

This week, I have an example of an older formula I reworked recently to simplify and streamline the logic using some tricks I've learned over the years.

The formula is simple; it marks dates that share the same month and year. The original formula looks like this:

=IF(AND(YEAR($B$5)=YEAR(D5),MONTH($B$5)=MONTH(D5)),"x","")

The improved formula looks like this:

=IF(TEXT($B$5,"mmyyyy")=TEXT(D5,"mmyyyy"),"x","")

Notice that we've cut the number of function calls in half. The original formula needs six, while the improved formula needs just two.

A formula to mark dates with the same month and year

[Download the workbook and read the full explanation]

This is a good example of how a better understanding of Excel's functions can help you create better formulas. The improved formula is more compact, easier to read, and easier to extend. The article above has a complete explanation. Download the worksheet to see how it works.

Excel formulas

We maintain a list of over 500 working formulas here.

If you need more structure, we also offer video training.

Have a great weekend!

Dave

The Exceljet newsletter is free and sent weekly on Fridays. Each week, I take a detailed look at one useful Excel formula. You can sign up on our home page.

 

Exceljet Logo
Exceljet
P.O. Box 4804
Salt Lake City, UT 84110

Copyright © 2024 Exceljet, All rights reserved.
You received this email because you are subscribed to our newsletter.
To unsubscribe, click the link below.