这段改变颜色的VBA代码有什么有关问题?为什么无论改哪个位置都

fieldset{padding:10px;}

这段改变颜色的VBA代码有什么问题?为什么无论改哪个位置都会变色?VB code

Private Sub Worksheet_Change(ByVal Target As Range)    Application.EnableEvents = false    On Error Goto ENEV    REM add your code below    If ((Target.Column >= 5) and (Target.Column <= 8)) or (Target.Column >= 14) Then        if IsNumeric(Target) then            If Target > 0 Then                Target.Font.Color = RGB(255,0,0)            Elseif Target < 0 Then                Target.Font.Color = RGB(0,128,0)            Else                Target.Font.Color = RGB(128,128,138)            End If        End if    End If    ENEV:    Application.EnableEvents = trueEnd Sub

——解决方案——————————————————–我这测试好像是正常的——解决方案——————————————————–用这个试试:VBScript code

Private Sub Worksheet_Change(ByVal Target As Range)    Application.EnableEvents = False    On Error GoTo ENEV    Rem add your code below    With Target        If ((.Column >= 5) And (.Column <= 8)) Or (.Column >= 14) Then            If IsNumeric(Target) Then                If .Value > 0 Then                    .Font.ColorIndex = 3                ElseIf .Value < 0 Then                    'Target.Font.Color = RGB(0, 128, 0)                    .Font.ColorIndex = 10                Else                    .Font.ColorIndex = 48                End If            End If        Else            .Font.ColorIndex = 0        End If    End WithENEV:    Application.EnableEvents = TrueEnd Sub爱上一个人的时候,总会有点害怕,怕得到他;怕失掉他。

这段改变颜色的VBA代码有什么有关问题?为什么无论改哪个位置都

相关文章:

你感兴趣的文章:

标签云: