Highlight Changes in PivotFields of two PageFields

GerdMüller

New Member
Joined
Oct 28, 2015
Messages
2
Hello All,

I'm new to VBA and this forum so please be lenient towards me. After hours of unsuccessful searching the internet for a solution, I resort to this forum and hope that you can help me.

I have the following Pivot table with pagefields like below


-- removed inline image ---


and


-- removed inline image ---


and what I want is the following via a macro


-- removed inline image ---



The dates and their corresponding data, which were not displayed the PageFields 42296 but in the PageFields 42297 should be highlighted.

Here's my best try so far:

Code:
Sub FormatPT2()
  Dim oldDates As Variant
  Dim c As PivotItem
  Dim strPvtFld As String
  With ActiveSheet.PivotTables("PivotTable1")
  .PivotFields("Date").CurrentPage = CStr(Int(CDbl(Application.WorksheetFunction.WorkDay(Now(), -7))))
  
  Set oldDates = .PivotFields("Date of Occurence").PivotItems
    
    .PivotFields("Date").CurrentPage = CStr(Int(CDbl(Application.WorksheetFunction.WorkDay(Now(), -6))))
    ' apply formatting to each row if condition is met
    For Each c In .PivotFields("Date of Occurence").PivotItems
    ' apply formatting to each row if condition is met
      If Application.WorksheetFunction.IsNA(Application.WorksheetFunction.Match(c, oldDates, 0)) Then
          'something with Interior.color = vbYellow
      End If
    Next
  End With
  
End Sub

But this appears still far from working. Excel 2010 is the version I'm working with.

Any help is greatly appreciated
 
Last edited:

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
What I have:


-- removed inline image ---


and


-- removed inline image ---


what I want via a macro:


-- removed inline image ---
 
Upvote 0

Forum statistics

Threads
1,214,967
Messages
6,122,503
Members
449,090
Latest member
RandomExceller01

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