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:


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
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.
    Ankit · 12 days ago
    Thanks a lot! It helped.
  • To post as a guest, your comment is unpublished.
    David Cardoso · 20 days ago
    Superb! very useful! Thanks a million! Cheers!
  • To post as a guest, your comment is unpublished.
    Volkan Yılmaz · 1 months ago
    Thank you. Awesome
  • To post as a guest, your comment is unpublished.
    ian · 3 months ago
    there's a question that it kept showing "Range not found",how can i fix it
  • To post as a guest, your comment is unpublished.
    Henrique · 5 months ago
    Awesome job, it works exactly like the explanation.Thank you
  • To post as a guest, your comment is unpublished.
    Bob Thomas · 5 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 · 5 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 · 6 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 · 6 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.
    Filip · 7 months ago
    i want use it, but dont working :-/
  • To post as a guest, your comment is unpublished.
    Polynon · 7 months ago
    Just a note if this isn't working for you, the quotation marks used in the example above don't parse a formula correctly and give you a "Formula Parse Error".

    The correct one is:

    =getHex("A2:A16")

    rather than:

    =getHex(“A2:A16”)
    • To post as a guest, your comment is unpublished.
      skyyang · 7 months ago
      Hi, Polynon,
      Thank you for your comment, the double quote around the cell reference should be English punctuation.
      I have updated it.
  • To post as a guest, your comment is unpublished.
    Lydia · 1 years ago
    Top, Danke!