• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Adding Conditioning to pivot table

k3vsmith

Member
Hello,
I inherited a macro from a previous co-worker and need to make adjustments to his code. See attached for his pivot table code.
The pivot table works well I just want to make the following change:
On Transaction Finish Date Missing fields - Any that are a Yes - highlight in RED
On Tranaction Control Effective To Date Error fields - Any that are a Yes - highlight in RED
On Tranaction Control Effective To Date Warning fields - Any that are a Yes - highlight in Yellow

Any help is appreciated.
 

Attachments

Figured it out. Added this:

Code:
'define column header constants
Const cnDateMissing = "ae1"
Const cnDateError = "af1"
Const cnDateWarning = "ag1"

'dimension module level variables
Dim wsInput As Worksheet
Dim pvT As PivotTable
Dim pvF As PivotField
'set the missing date color

    Set pvF = pvT.PivotFields(wsInput.Range(cnDateMissing).Value)
    With pvF.DataRange

        .FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="=""Yes"""
        .FormatConditions(1).Interior.Color = 255
       
    End With
       

    'set the date error color

    Set pvF = pvT.PivotFields(wsInput.Range(cnDateError).Value)
    With pvF.DataRange

        .FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="=""Yes"""
        .FormatConditions(1).Interior.Color = 255
       
    End With


    'set the date warning

    Set pvF = pvT.PivotFields(wsInput.Range(cnDateWarning).Value)
    With pvF.DataRange

        .FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="=""Yes"""
        .FormatConditions(1).Interior.Color = 65535
       
    End With
 
Back
Top