How to Highlight Yearly Maximum Values with Dynamic Conditional Formatting in Excel
Question details
The user wants to create a conditional formatting rule that automatically highlights the maximum value for each year in a dataset where new daily rows are continuously added.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Maintaining a growing dataset with daily entries and needing the highest value of each year to be highlighted without manually adjusting the formatting range every time new data is pasted or typed.
- Observed behavior
- Setting up a dynamic formula-based conditional formatting rule that adapts to expanding rows while correctly calculating the yearly maximums.
Ensure your data is organized with dates in one continuous column and the numerical values you want to evaluate in another. Verify that your date column contains valid date serial numbers, not just text strings that look like dates, to prevent formula calculation errors.
Use an Excel Table for Automatic Range Expansion
Converting your data into a structured Excel Table is the most reliable method, as it automatically expands conditional formatting ranges and named references when new data is added.
When dealing with continuously growing datasets, standard ranges can be problematic because conditional formatting rules may not expand consistently. Excel Tables solve this by automatically absorbing new rows into the table's structure, ensuring any applied formatting rules scale dynamically.
Select any cell within your dataset and press Ctrl+T (or go to Insert > Table). Ensure 'My table has headers' is checked and click OK.
Select the data rows in your new Table. Go to the Home tab on the ribbon, click Conditional Formatting, and choose New Rule.
Choose 'Use a formula to determine which cells to format'. Enter the conditional formatting formula adapting to your columns. For example, if dates are in column A and values in column E: =($E2=MAX(IF(YEAR($A2)=YEAR($A$2:$A$10000),$E$2:$E$10000,"")))
Click the Format button, select a fill color (like yellow or green) to highlight the maximum value, and click OK twice to apply the rule.

Apply Formatting to a Large Fixed Range Ignoring Blanks
If you prefer not to use an Excel Table, you can apply the formatting rule to a much larger range (e.g., up to row 10,000) and add a specific condition to ignore empty cells.
Use a Dynamic Range Formula with OFFSET
Use the OFFSET and COUNTA functions within your conditional formatting formula to dynamically calculate the height of your dataset based on the number of non-empty cells.
Easily Manage Dynamic Conditional Formatting with WPS Spreadsheet
WPS Spreadsheet provides robust support for advanced array formulas, structured tables, and conditional formatting just like Microsoft Excel. It's a powerful, free tool that makes managing growing daily datasets and complex analytical formatting a breeze.
- 1. Open your workbook: Launch WPS Spreadsheet and open your existing Excel (.xlsx) workbook containing the daily data.
- 2. Format as Table: Select your dataset and press Ctrl+T to quickly convert it into a structured Table.
- 3. Apply Conditional Formatting: Go to the Home tab, click Conditional Formatting > New Rule, and paste your dynamic MAX formula to highlight yearly peaks.

Frequently Asked Questions
Why is my conditional formatting range not expanding when I add new rows?
This usually happens when applying formatting to a standard data range instead of a structured Table. Excel may not automatically update the 'Applies to' range of the conditional formatting rule when you paste or type below the last row. Converting your data to a Table by pressing Ctrl+T resolves this issue by automatically extending formatting to new rows.
Can I use MAXIFS instead of the MAX(IF(...)) array formula?
Yes. If you are using a newer version of Excel or WPS Office, you can simplify the logic and avoid array formulas using MAXIFS. The equivalent formula would be: =$E2=MAXIFS($E:$E, $A:$A, ">="&DATE(YEAR($A2),1,1), $A:$A, "<="&DATE(YEAR($A2),12,31)). This approach often performs faster on large datasets.
Why does my conditional formatting highlight blank cells at the bottom of the range?
If you applied the rule to a large fixed range (e.g., rows 2 to 10000) that includes empty rows, the formula might evaluate those blanks as zeroes or return unexpected true matches. To fix this, you must append a condition to verify the cell isn't blank. In a formula, you can multiply your main logic by ($A2<>"") so that empty rows are forced to evaluate as false.




