2
我有一个vba代码问题。我不知道为什么,但它消除了公式前面的等号...也许有人知道如何解决它?Excel VBA从公式中删除等号
这里是Excel工作表的全部源代码:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
For Each c In Target.Cells
If Not Intersect(c, Range("X:AI")) Is Nothing Then
If c > Range("H" & c.Row).Value Or c < Range("G" & c.Row).Value Then
c.Font.ColorIndex = 3
ElseIf c <= Range("H" & c.Row).Value And c >= Range("G" & c.Row).Value Then
c.Font.ColorIndex = 10
End If
Dim frml1 As String
Dim frml2 As String
frml1 = "LARGE(X" & c.Row & ":AI" & c.Row & ";1)"
frml2 = "SMALL(X" & c.Row & ":AI" & c.Row & ";1)"
Range("AK" & c.Row).Value = "=AVERAGE(X" & c.Row & ":AI" & c.Row & ")"
Range("AJ" & c.Row).Value = "=" & frml1 & " - " & frml2
ElseIf Not Intersect(c, Range("AL:AM")) Is Nothing Then
If c > Range("K" & c.Row).Value Or c < Range("J" & c.Row).Value Then
c.Font.ColorIndex = 3
ElseIf c <= Range("K" & c.Row).Value And c >= Range("J" & c.Row).Value Then
c.Font.ColorIndex = 10
End If
...
ElseIf Not Intersect(c, Range("AU:AU")) Is Nothing Then
If c > Range("Q" & c.Row).Value Or c < Range("P" & c.Row).Value Then
c.Font.ColorIndex = 3
ElseIf c <= Range("Q" & c.Row).Value And c >= Range("P" & c.Row).Value Then
c.Font.ColorIndex = 10
End If
ElseIf Not Intersect(c, Range("AY:AY")) Is Nothing Then
If c > Range("T" & c.Row).Value Or c < Range("S" & c.Row).Value Then
c.Font.ColorIndex = 3
ElseIf c <= Range("T" & c.Row).Value And c >= Range("S" & c.Row).Value Then
c.Font.ColorIndex = 10
End If
End If
Next c
End Sub
“,”或“;”是区域设置中的设置。基本上取决于你的语言 – Andreas
Excel分隔符取决于语言...例如,在excel中使用丹麦语LP,那么有必要用分号分隔,因为逗号已经用于十进制分隔,而不是英语中的千位分隔符。 – 2016-11-16 09:06:39
每天学习新东西! – ClintB