我有一段代码将百分比作为颜色编码的条件。我想知道是否可以基于其他列添加条件,然后将其应用于受影响的列。
因此,如果“默认辅助时间0中花费的时间”列的时间超过1小时,则适用我的颜色编码条件语句。但是,如果此列的时间少于1小时,则颜色编码将不适用。
下面是我的代码示例。我只包含与该问题相关的部分,因为我知道整个代码都可以工作。
With .CalculatedFields.Add("DefaultCode_0_Time", "=DefaultCode_0/86400")
.Orientation = 4
.Function = -4157
.NumberFormat = "[h]:mm:ss"
.Caption = "Time Spent in Default Aux Time 0"
End With ####This is the piece I wanted factored in to the condition.
If this column is more than ah hour, I want the color coding
condition below applied. If it is less than 1 hour, then I do
not want the color coding condition below applied####
With .CalculatedFields.Add("Aux_0_Percentage", "=ACD_Aux_Outtime/DefaultCode_0")
.Orientation = 4
.NumberFormat = "#,##0.0%"
.Caption = "Default Aux Time 0 % for Outbound Calls"
End With
Set xlObj = .PivotFields("Default Aux Time 0 % for Outbound Calls").DataRange.FormatConditions.Add(1, 1, "0.00", "0.4") '(xlCellValue, xlBetween, "0-40%")
xlObj.StopIfTrue = False
xlObj.ScopeType = 1
With xlObj.Font
.Color = -16383844
.TintAndShade = 0
End With
With xlObj.Interior
.PatternColorIndex = -4105 'xlAutomatic
.Color = 13551615 'red
.TintAndShade = 0
End With
Set xlObj = Nothing
Set xlObj = .PivotFields("Default Aux Time 0 % for Outbound Calls").DataRange.FormatConditions.Add(1, 1, "0.40", "0.50") '(xlCellValue, xlBetween, "40-50%")
xlObj.StopIfTrue = False
xlObj.ScopeType = 1
With xlObj.Font
.Color = -16752384
.TintAndShade = 0
End With
With xlObj.Interior
.PatternColorIndex = -4105 'xlAutomatic
.Color = 10284031 'yellow
.TintAndShade = 0
End With
Set xlObj = Nothing