Alternating Colors for Groups and Filter Issue in Google Sheets

Are you tired of dealing with the filter issue associated with alternating colors for groups in Google Sheets? Don’t worry, I’ve got a solution for you! In this article, I will walk you through the steps to sort out this problem and ensure that your alternating colors remain intact even when filtering data.

The Problem: Highlighting Rows with Filter

We all know that we can use conditional formatting to get alternating colors for groups of rows in Google Sheets. However, this method has an issue when it comes to using filters. The alternating colors get refreshed and break when we filter out certain rows, making it difficult to maintain consistency in our data visualization.

Introducing the Solution

To overcome this complicated problem, I have come up with a simple workaround using a helper tab and a few helper columns. This method will allow you to sort out the filter issue associated with alternating colors for groups in Google Sheets.

Filter Issue with Highlighting Rows

Steps to Sort Out the Filter Issue

Follow these steps to ensure that your alternating colors for groups remain intact even when you filter your data:

  1. Start by creating your list in column A in ‘Sheet1’. For testing purposes, you can use the same fruit data mentioned above.

  2. Label cell E1 as “Helper 1” and cell F1 as “Helper 2” in ‘Sheet1’.

  3. In cell E2, copy and paste the following formula: =subtotal(103,A2). Drag this formula down until the last row that contains a value in column A (e.g., E12).

  4. Create a new sheet called ‘Helper Tab’ and keep only three columns. In cell A1 of the ‘Helper Tab’, enter the following filter formula: =filter({row(Sheet1!A1:A),Sheet1!A1:A},Sheet1!E1:E=1). This formula will populate values in columns A and B of the ‘Helper Tab’.

  5. In cell C1 of the ‘Helper Tab’, enter the following formula: =ArrayFormula(IFNA(match(B1:B,unique(B1:B),0))). This formula assigns sequential numbers based on groups.

  6. Go back to ‘Sheet1’ and in cell F2, enter the following Vlookup formula: =ArrayFormula(IFNA(vlookup(row(A2:A),'Helper Tab'!A1:C,3,0))). This formula ensures that the sequential numbers remain unbroken even when rows are hidden.

  7. Select the range A2:A in ‘Sheet1’ and go to Conditional Formatting (Format menu). Enter the following custom formula rules one by one:

    • Rule 1: =and(isodd($F2),not(isblank($F2)))
    • Rule 2: =and(iseven($F2),not(isblank($F2))
  8. Choose two different colors for the above two rules to achieve the desired alternating colors for groups.

By following these steps, you will be able to maintain the alternating colors for groups even when filtering your data.

The Purpose of the Helper Columns and Helper Tab

Now, let’s dive into the purpose of the helper columns and the helper tab to gain a better understanding of how this solution works.

Subtotal as Counta

The formula in column E (Helper 1) of ‘Sheet1’ uses the Subtotal function with number 103, which is equivalent to Counta. The formula counts the visible rows in column A. If any rows are hidden, the corresponding cell value in column E will be 0. We will use this column as a criteria column in the Filter formula.

Helper Tab Formula 1 – Filter

In the ‘Helper Tab’, cell A1 has a Filter formula that filters visible items from the list in ‘Sheet1’ column A. The formula also returns the corresponding row numbers, which will be used later.

Helper Tab Formula 2 – Array Formula for Alternating Colors for Groups

In the same ‘Helper Tab’, cell C1 contains an array formula that assigns sequential numbers based on groups. This formula can be used to highlight alternating colors for groups in column B of the ‘Helper Tab’.

The Vlookup formula in cell F2 of ‘Sheet1’ uses the row numbers as search keys and matches the same row numbers in column A of the ‘Helper Tab’. This ensures that the sequential numbers remain unbroken in column F of ‘Sheet1’, even when rows are hidden. The conditional formatting rules for alternating colors for groups are based on this column.

Conclusion

With this workaround, you can easily achieve alternating colors for groups in Google Sheets without worrying about the filter issue. Follow the steps provided and enjoy hassle-free data visualization.

If you want to learn more tips and tricks for Google Sheets, be sure to visit Crawlan.com for additional insights.

Remember, your data deserves to be visually appealing and organized. Happy Sheets-ing!

Related posts