Excel: Highlighting Parent and Child Rows or Columns

Published on

When highlighting parent and child rows or columns, I mean applying conditional formatting to adjacent cells. How can this be done in Excel?

For example, you might want to check the value in one cell and highlight that cell along with the next cell, which are in two different rows. This is particularly useful when you have a title row followed by a value row, creating multiple pairs of rows.

Table 1:

Katina Chen
89
Liam Smith
95
Rimisha Patel
89
Noah Davis
91

In another scenario, you may want to check the value in one cell and highlight that value along with the next value in an adjacent column.

Table 2:

Katina Chen89Liam Smith95Rimisha Patel99Noah Davis91

Let’s see how to create a new rule for this in Excel using Conditional Formatting.

Example of Highlighting Parent and Child Rows in Excel

Assume the names in Table #1 above are in the range B2:B9 in an Excel spreadsheet. We will highlight the names in one row and their marks in another row if the mark is greater than 90.

Highlighting parent and child rows in Excel

Here are the steps you should follow to highlight two adjacent cells in an Excel spreadsheet:

  1. Select the range B2:B9.
  2. Navigate to the Home tab, and under the Styles group, click Conditional Formatting > New Rule.
  3. In the New Formatting Rule dialog box that opens, select “Use a formula to determine which cells to format.”
  4. Enter the following formula in the provided field: =OFFSET(B2, MOD(ROW(A1), 2),)>90
  5. Click the Format button and choose a formatting style, preferably a fill color other than white.
  6. Click OK to close the Format Cells dialog box, and then click OK again to close the New Formatting Rule dialog box.

This will highlight the names and marks of those whose marks are greater than 90.

This is an example of how to highlight parent and child rows in Excel.

Note: When you use this formula in your Excel spreadsheet for a different range, simply replace B2 with the cell reference of the first value in the column (the top-left cell in the range if you are applying it in a 2D array).

Example of Highlighting Parent and Child Columns in Excel

If you refer to the second table, you can see that the data in the example above is arranged in a row. Therefore, we need to highlight two adjacent columns that meet the criterion in one column.

Assume the range is B2:I2.

Highlighting parent and child columns in Excel

You can follow all the steps from the previous example, but in the first step, you should select the range B2:I2, and in the fourth step, you should use the following formula: =OFFSET(B2, 0, MOD(COLUMN(A1), 2))>90

This will help us highlight parent and child columns in Excel. The “Note” from the previous example applies here as well.

How Do the Formulas Highlight Linked Data in Adjacent Cells?

Both Excel highlight rules use the OFFSET function to offset rows or columns based on the orientation of the data.

The formula for Table #1 offsets one row in the title row to fetch the mark. In the rows with marks, it offsets zero rows. Essentially, the formula evaluates the marks in each row, and if they are greater than 90, the highlighting is applied.

If you enter MOD(ROW(A1), 2) in any cell and drag it down, it will generate an array of values such as {1; 0; 1; 0; 1; 0; …}. These values are used to offset the rows in each case.

The same applies to the second conditional formatting rule, where we used the COLUMN function instead of the ROW since we are applying the rule to columns and offsetting columns, not rows.

Resources

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Compare Two Tables for Differences in Excel

To compare two tables with similar data for differences, you can use the XLOOKUP...

Calculate Weighted Average in Pivot Table in Google Sheets

You can calculate a weighted average in a Pivot Table using a custom formula...

Summarize Data and Keep the Last Record in Google Sheets

In Google Sheets, we can summarize data (like sum, average, min, max, count) using...

How to Retrieve the Last Record in Each Group in Excel

As part of data analysis, you may need to retrieve the last record from...

More like this

Compare Two Tables for Differences in Excel

To compare two tables with similar data for differences, you can use the XLOOKUP...

How to Retrieve the Last Record in Each Group in Excel

As part of data analysis, you may need to retrieve the last record from...

How to Perform Case-Sensitive XLOOKUP in Excel with EXACT

We may not always need to perform a case-sensitive XLOOKUP for product names in...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.