Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to filter rows based on cell color in Google sheet?

Normally, we can filter rows by a certain color in Excel quickly with the Filter feature, but, in Google sheet, the Filter function does not support this operation. This article, I will talk about how to filter rows by color in Google sheet.

Filter rows based on color in Google sheet


Filter rows based on color in Google sheet


Please apply the following steps to filter data based on color.

1. Click Tools > Script editor, see screenshot:

2. In the opened project window, please copy and paste the below script code to replace the original code in the code module, see screenshot:

function getHex(input) {
  return SpreadsheetApp.getActiveSpreadsheet().getRange(input).getBackgrounds();
}

3. And then save the code window, and a prompt box is popped out to remind you to give the project a name, see screenshot:

4. After saving the script code, go back the sheet, and enter this formula: =getHex("A2:A16") into a blank cell next to your data range, and then press Enter key, the color index of each row has been displayed in the helper column, see screenshot:

5. Then you just need to filter rows based on this helper column, please click the helper column header, and then click Data > Filter, see screenshot:

6. And then click the drop-down button in the helper column, in the expanded pane, choose and check the color index that you want to filter from the list box, see screenshot:

7. Click the OK button, the rows which filled with the specific cell color have been filtered as following screenshot shown:


Recommended Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 71%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 82% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Henrique · 1 months ago
    Awesome job, it works exactly like the explanation.Thank you
  • To post as a guest, your comment is unpublished.
    Bob Thomas · 1 months ago
    Great workaround! I tried repeatedly to highlight duplicates in an Excel spreadsheet then sort by cell color but since the file was so large (373K + rows) the sort would "hang", and never complete. I decided to try Google Sheets and although I could only format about 100K rows at a time (had to do a format 4x) your workaround worked perfectly. Plus, scrolling down the page with Google Sheets was infinitely faster than with Excel. Thanks for the great hack!
  • To post as a guest, your comment is unpublished.
    Ramón · 1 months ago
    I understand that the topic is about a script for such a need. But a simpler option can be to handle conventions by color. Example: Green color indicates CLIENT, Color Orange. INTERESTED, Color Yellow indicates NOT INTERESTED .. Then add a column status and then filter for the desired state.
  • To post as a guest, your comment is unpublished.
    Tarek Allam · 2 months ago
    This is a great script it really helped me solve a problem, however I modified it a bit because my range is not fixed, I keep adding rows to the sheet and I don't want to modify the formula everytime I add a new row, so I used the following formula instead:

    =ARRAYFORMULA(IF(NOT(ISBLANK(A2:A)),getHex("A2:A"),""))

    The problem is when I change the color of a column the hex value does not change even if I refresh the sheet, the only solution I found is to delete the formula then paste it again so it loads again, anyone could help with a solution to this?
  • To post as a guest, your comment is unpublished.
    Tarek · 2 months ago
    This is a great script it really helped me solve a problem, however I modified it a bit because my range is not fixed, I keep adding rows to the sheet and I don't want to modify the formula everytime I add a new row, so I used the following formula instead:

    =ARRAYFORMULA(IF(NOT(ISBLANK(A2:A)),getHex("A2:A"),""))

    The problem is when I change the color of a column the hex value does not change even if I refresh the sheet, the only solution I found is to delete the formula then paste it again so it loads again, anyone could help with a solution to this?