Use formula conditional formatting to handle overflow arrays in Excel
Direct formatting of overflow arrays in Excel can cause problems, especially when the data shape or size changes. Formula-based conditional formatting rules allow automatic formatting when data parameters change. Adding a dollar sign ($) before a column reference applies a rule to all rows in the data.
In Excel, you can apply direct formatting to the values or background of a cell to make the spreadsheet easier to read. However, when an Excel formula returns a set of values (called overflow arrays), applying direct formatting will cause problems if the size or shape of the data changes.
Suppose you have this spreadsheet with spillover results from the PIVOTBY formula that shows the number of viewers per sport in each region over the past four years.
Since the PIVOTBY function does not contain parameters that allow you to format the results, it is difficult to distinguish between title rows, data rows, subtotal rows, and total rows.
At this point, you might want to apply direct formatting through the Fonts group on the Start tab of the ribbon to intuitively distinguish different types of rows in your data.
However, if you later modify the parameters in the PIVOTBY formula, or the results are enlarged or reduced due to changes in the original data, the direct formatting you applied will not be adjusted accordingly. This is because direct formatting in Excel is associated with cells, not with the data they contain. See the screenshot below where the data has been reduced, but the direct formatting is still applied to the same row, which can cause confusion.
Instead, you should use conditional formatting, which allows you to format them based on the values of the cells and rows.
Select all the data (and some extra rows at the bottom to allow vertical growth), and on the Start tab of the ribbon, click Conditional Format > Manage Rules.
Next, in the Conditional Format Rule Manager dialog box, click New Rule.
For every rule you will create to format overflow arrays, you need to use formulas. Therefore, in the Select Rule Type area of the New Format Rule dialog box, select the last option Use formula to determine which cell to format.
The first rule you want to create is related to the title line. Specifically, you want these cells to be on a gray background.
To do this, take a moment to determine what makes the title row different from the other rows in the table. In this example, the title row is the only row in column G that does not contain numbers. So, in the Formula field, type:
<code>=ISTEXT($G1)</code>
Since the ISTEXT function treats empty cells and cells containing text as text values, the conditional formatting rules will consider cells G1 to G3 to contain text, while the rest of the cells in the G column contain numeric values.
Importantly, adding a dollar sign ($) before a column reference repairs the conditional formatting to this column while allowing Excel to apply rules to the rest of the rows.
Finally, because you initially selected the data from columns A to G, the conditional format will be applied to the entire row that satisfies the condition.
Now, click Format to select the format of the title row. In this case, you want them to be gray. Then, click OK in the Format Cell and Edit Format Rules dialog box.
When you click Apply in the Conditional Format Rule Manager dialog box, you will see that only the G columns contain empty cells or text (in other words, the title row) are filled with gray.
Next, you want to format the subtotal rows so they are filled with light green.
Take a closer look at the data again and see which conditions you can use to apply the format to these rows only. In this example, the subtotal row contains text in column A, but nothing in column B. Additionally, since the total row also meets these conditions, you need to exclude any cells in column A that contain the word "total".
With the Conditional Format Rule Manager dialog box still open, click New Rule and select the option that allows you to format cells using formulas. This time, in the formula field, type:
<code>=AND($A1"",$B1="",$A1"Grand Total")</code>
in:
- The AND function allows you to specify multiple conditions in parentheses.
- $A1" ""Tell Excel to find cells that do not contain () empty cells ("") in column A.
- $B1="" Tell Excel to find cells containing (=) empty cells ("") in column B, and
- $A1"Grand Total" tells Excel to exclude () any cells in column A that contain the text "Grand Total".
As with the previous rules, remember to insert the $ symbol before the column reference to allow Excel to apply the same rule to all selected rows.
Now, click Format to select a light green fill color, and after closing the Format Cells and Edit Format Rules dialog boxes, click Apply to see that the subtotal rows are filled with light green.
Finally, you want the cells in the total row to be filled with darker green.
Since the total row is the only row in column A that contains the word "total", this is the condition you can use for conditional formatting. In the Conditional Format Rule Manager dialog box, click New Rule, and then select the last option in the Select Rule Type list. Now, in the Formula field, type:
<code>=$A1="Grand Total"</code>
Next, click Format and select the bold green fill color you want to apply to the cell that matches this condition. Now when you close the Format Cells and Edit Format Rules dialogs and click Apply in the Conditional Format Rule Manager dialog, you will see that the total rows are in this format.
Now that you have applied all the rules, click Close in the Conditional Format Rule Manager dialog box. Then, adjust some data in the original table and see if the overflow results and their formats are updated accordingly.
In this example, even if I delete 12 rows from the original data table, the overflowing PIVOTBY results are still formatted correctly, the title behavior is gray, the subtotal behavior is light green, and the total behavior is bold green.
If you need to change the rules you have created and applied, simply select any cell in the data and click Conditional Format > Manage Rules to restart Conditional Format Rules Manager. Then, double-click the rule to change its conditions.
The above is the detailed content of How to Format a Spilled Array in Excel. For more information, please follow other related articles on the PHP Chinese website!

This tutorial shows how to convert numbers to text in Excel 2016, 2013, and 2010. Learn how to do this using Excel's TEXT function and use numbers to strings to specify the format. Learn how to change the format of numbers to text using the Format Cell… and Text to Column options. If you use an Excel spreadsheet to store long or short numbers, you may want to convert them to text one day. There may be different reasons to change the number stored as a number to text. Here is why you might need to have Excel treat the entered number as text instead of numbers: Search by part rather than the whole number. For example, you might want to find all numbers containing 50, such as 501

We recently delved into the basics of Excel Data Validation, exploring how to set up a straightforward drop-down list using a comma-separated list, cell range, or named range.In today's session, we'll delve deeper into this functionality, focusing on

This tutorial shows simple steps to create a drop-down list in Excel: Create from cell ranges, named ranges, Excel tables, other worksheets. You will also learn how to make Excel drop-down menus dynamic, editable, and searchable. Microsoft Excel is good at organizing and analyzing complex data. One of its most useful features is the ability to create drop-down menus that allow users to select items from predefined lists. The drop-down menu allows for faster, more accurate and more consistent data entry. This article will show you several different ways to create drop-down menus in Excel. - Excel drop-down list - How to create dropdown list in Excel - From the scope - From the naming range

The PDF format, known for its ability to display documents independently of the user's software, hardware, or operating system, has become the standard for electronic file sharing.When requesting information, it's common to receive a well-formatted P

This short tutorial describes 4 possible ways to convert Excel files to PDF - using Excel's Save As feature, Adobe software, online Excel to PDF converter, and desktop tools. Converting an Excel worksheet to a PDF is usually necessary if you want other users to be able to view your data but can't edit it. You may also want to convert Excel spreadsheets to PDF format for use in media toolkits, presentations, and reports, or create a file that all users can open and read even if they don't have Microsoft Excel installed, such as on a tablet or phone. Today, PDF is undoubtedly one of the most popular file formats. According to Google

This tutorial explains the Excel SUMIF function in plain English. The main focus is on real-life formula examples with all kinds of criteria including text, numbers, dates, wildcards, blanks and non-blanks. Microsoft Excel has a handful o

In this article, you will learn how to build an Excel IF statement for different types of values as well as how to create multiple IF statements. IF is one of the most popular and useful functions in Excel. Generally, you use an IF statem

This tutorial shows how to sum a column in Excel 2010 - 2016. Try out 5 different ways to total columns: find the sum of the selected cells on the Status bar, use AutoSum in Excel to sum all or only filtered cells, employ the SUM function


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Linux new version
SublimeText3 Linux latest version

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version
God-level code editing software (SublimeText3)
