|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Private Sub Worksheet_Change(ByVal Target As Range)
- If Target.Row = 1 Then Exit Sub
- If Target.CountLarge > 1 Then Exit Sub
- If Target.Offset(-1, 0) = "" Then Exit Sub
- Dim num#
- Application.EnableEvents = False
- num = 1 * WorksheetFunction.Substitute(WorksheetFunction.Substitute(Target.Offset(-1, 0), "↑", ""), "↓", "")
- Target = 1 * WorksheetFunction.Substitute(WorksheetFunction.Substitute(Target, "↑", ""), "↓", "")
- With Target
- If .Value < num Then
- .Value = Format(.Value, "0.00↓")
- .Font.Color = RGB(0, 255, 0)
-
- ElseIf .Value > num Then
- .Value = Format(.Value, "0.00↑")
- .Font.Color = RGB(255, 0, 0)
-
- End If
- End With
- Application.EnableEvents = True
- End Sub
复制代码 |
|