Skip to main content

How to quickly shade alternating filtered rows in Excel?

Author: Xiaoyang Last Modified: 2014-06-03

To improve the readability, some people may apply shading color to every other row in Excel. The conditional formatting can help you quickly solve this. For more detailed information, please visit: How to shade alternate rows in Excel?

But, if you need to shade alternating filtered rows in Excel, you can quickly apply shading color to the filtered rows in Excel as follows:

Shade alternating filtered rows with Conditional Formatting
Too complicated!

Shade alternating filtered rows with VBA code
For advanced users!

Quickly shade alternating filtered rows with Kutools for Excel
Simple, easy for all users!

arrow blue right bubbleShade alternating filtered rows with Conditional Formatting

By doing this, you should do with two major steps:

A: Shade the range alternately (step1-step5)

B: Filter the data you need, the shading will automatically change (step6-step9)

1. Select the range that you want to shade. If filtering is already in play, be sure to remove the filter to select the full range. In this example, we will select the range (A2:G25).


2. Then click Home > Conditional Formatting > New Rule, and a New Formatting Rule dialog box will appear.

3. And click the last option Use a formula to determine which cells to format in Select a Rule Type, and enter this formula “=MOD(SUBTOTAL(3,$A$1:$A2),2)” into the box.


4. Then click Format button, and a Format Cells dialog box will pop out. Click Fill, and select a color you like. See screenshot:


5. And click OK, it will return to the New Formatting Rule, and now you can see the color in the Preview box. Then click OK. And the range which you select has been shaded alternately.


6. Finished the above steps, now you need to filter the date. Click Data > Filter, Excel will add drop-down arrows to the column headers.


7. Then you can choose the criteria you need. In this example, I will filter the customer name is Minimall. Put the cursor at the Customer drop down arrows and click it, a menu will appear, choose Text Filters > Contains… see screenshot:


8. And a Customer AutoFilter dialog box will pop out. Enter Minimall in the contains box.


9. And then click OK. All of the filtered rows have been shaded alternately. See screenshot:


arrow blue right bubbleShade alternating filtered rows with VBA code

The first method is somewhat complicated, and the following VBA code can help you quickly to shade filtered rows alternately.

Supposing you have filtered the data, see screenshot:


1. Click Developer>Visual Basic, a new Microsoft Visual Basic for applications window will be displayed, click Insert > Module, and input the following code into the Module:

VBA: alternately shading the filtered rows

Sub ShadeRows()
Dim Rng As Range
Dim WorkRng As Range
Dim shadeIt As Boolean
shadeIt = True
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each Rng In WorkRng.Rows
    If Not Rng.EntireRow.Hidden Then
        Rng.Interior.ColorIndex = _
        IIf(shadeIt, 15, xlNone)
        shadeIt = Not (shadeIt)
    End If
End Sub

2. Click doc-multiply-calculation-3 button to execute the code, a KutoolsforExcel dialog pops out for you to select a range to shade. See screenshot:


3. Then click OK. And the filtered data have been shaded alternately. See screenshot:


arrow blue right bubbleQuickly shade alternating filtered rows with Kutools for Excel

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 30 days. Get it Now .

With Kutools for Excel, you can easily and quickly to shade alternating filtered rows. You can get it done by following these steps:

1. Select the filtered data that you want to shade.

2. Click Kutools > Format Tools > Alternate Row Shading, see screenshot:


3. Then check Rows option from the Shade type in the Alternate Row/Column shading dialog box, and choose one color you like in the Shade color drop-down list, then check Conditional formatting from the Color method, at last choose number 1 from Shade every spin button. See screenshot:


4. And then click OK. The filtered data have been alternately shade. See screenshot:


Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


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!
Comments (1)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
The KUTOOLS method does not work for me on filtered data. I receive a dialog saying "This feature cannot process filtered data, please clear filter first."
There are no comments posted here yet
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations