Filtering Pivot Table to fill non-formatted cells with color.

Diesel24

New Member
Joined
Jun 13, 2017
Messages
11
Hi All,

I am sure that this is an easy fix for those that know what they are doing (unlike me).

I have a background color surrounding a pivot table in Excel, but when I filter out column entries, this leaves blank non-formatted cells in the pivot from the filtering. What I am wanting to do is fill this blank range with the surrounding color so no non-formatted cells are with the original range? I would like this to work automatically on the filtering without using a button.

Can anyone help me out with this?

I appreciate your expertise.

Regards,

Diesel24
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi

I understood you want to format cells beneath the filtered table:

Code:
' sheet module
Dim ad, pt As PivotTable, pad$

Private Sub Worksheet_Activate()
Set pt = Me.PivotTables(1)
Application.EnableEvents = 0
pt.ClearAllFilters
Application.EnableEvents = 1
pad = pt.TableRange1.Address
ad = Split(pad, "$")                                ' unfiltered table
End Sub

Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
Dim r As Range, s$, v
If Len(pad) = 0 Then
    MsgBox "Leave and return to this sheet.", 64, "Activation code required"
    Exit Sub
End If
Select Case pad = Target.TableRange1.Address        ' is the table filtered?
    Case False                                      ' yes
        v = Split(Target.TableRange1.Address, "$")
        s = "$" & ad(1) & "$" & CStr((CInt(v(4)) + 1)) & ":$" & ad(3) & "$" & ad(4)
        Set r = Me.Range(s)                         ' range to format
        r.Interior.ThemeColor = xlThemeColorAccent6
        r.Interior.TintAndShade = 0.8
    Case True                                       ' no extra format, only table style
        Set r = Me.Range(pad)
        r.Interior.Pattern = xlNone
        r.Interior.TintAndShade = 0
End Select
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,203,097
Messages
6,053,519
Members
444,669
Latest member
Renarian

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top