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:
But this appears still far from working. Excel 2010 is the version I'm working with.
Any help is greatly appreciated
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: