在模块1中,我声明了一个公共常量:
Public Const hueBoundryRed As Long = 0
在模块2中,我有以下代码可以完美运行:
With sheetALL.Cells(allFirstRow + aolNum, valueAddedCol)
.Font.Color = col_Black
.Value = valueAddedARE
If valueAddedARE <= hueBoundryRed Then
.Font.Color = col_Red
ElseIf valueAddedARE > hueBoundryRed And valueAddedARE <= 0.05 Then
.Font.Color = col_Amber
ElseIf valueAddedARE > 0.05 And valueAddedARE <= 0.3 Then
.Font.Color = col_Green
ElseIf valueAddedARE > 0.3 Then
.Font.Color = col_Blue
End If
End With
但是,如果我然后用模块1中的常量替换0.05和0.3:
Public Const hueBoundryAmber As Long = 0.05
Public Const hueBoundryGreen As Long = 0.3
然后当我在模块2中运行以下代码时,一切都默认为最终的ifelse条件并变为蓝色:
With sheetALL.Cells(allFirstRow + aolNum, valueAddedCol)
.Font.Color = col_Black
.Value = valueAddedARE
If valueAddedARE <= hueBoundryRed Then
.Font.Color = col_Red
ElseIf valueAddedARE > hueBoundryRed And valueAddedARE <= hueBoundryAmber Then
.Font.Color = col_Amber
ElseIf valueAddedARE > hueBoundryAmber And valueAddedARE <= hueBoundryGreen Then
.Font.Color = col_Green
ElseIf valueAddedARE > hueBoundryGreen Then
.Font.Color = col_Blue
End If
End With
为什么?