在工作簿中使用条件格式的问题

我有一个非常简单的表,我应用了条件格式化规则。 规则规定突出显示小于特定颜色的值。 但是,我发现当我将工作表复制到另一个工作簿时,突出显示的单元格的颜色会发生显着变化。 在这种情况下,它从绿色的阴影变成橙色的阴影。 这是个常见的问题吗? 有谁碰巧知道如何解决这个问题?

我无法复制这个问题。

请将下面的代码添加到问题工作簿中。

将光标放在源工作簿中显示为绿色的单元格上,并运行macrosTestCF() 。 然后将光标放在目标工作簿中的同一单元格上,然后再次运行macrosTestCF()

macros显示由条件格式设置的字体颜色。 我得到了两个工作簿相同的输出。 也许你会得到不同的输出。

Option Explicit Sub TestCF() Dim InxCF As Long With ActiveCell Debug.Print "Workbook " & ActiveWorkbook.Name & " Worksheet " & _ ActiveSheet.Name & " Cell " & ColNumToCode(ActiveCell.Column) & ActiveCell.Row For InxCF = 1 To .FormatConditions.Count Debug.Print " Format " & InxCF With .FormatConditions(InxCF) Debug.Print " Font colour: " & ColourToRGB(.Font.Color) End With Next End With End Sub Function ColourToRGB(ByVal Colour As Long) As String Dim Red As Long Dim Blue As Long Dim Green As Long Dim BlueGreen As Long Red = Colour Mod 256 BlueGreen = Colour \ 256 Green = BlueGreen Mod 256 Blue = BlueGreen \ 256 ColourToRGB = "RGB(" & Red & ", " & Green & ", " & Blue & ")" End Function Function ColNumToCode(ByVal ColNum As Long) As String Dim Code As String Dim PartNum As Long ' Last updated 3 Feb 12. Adapted to handle three character codes. If ColNum = 0 Then ColNumToCode = "0" Else Code = "" Do While ColNum > 0 PartNum = (ColNum - 1) Mod 26 Code = Chr(65 + PartNum) & Code ColNum = (ColNum - PartNum - 1) \ 26 Loop End If ColNumToCode = Code End Function