【发布时间】:2015-02-10 06:38:35
【问题描述】:
对于这样一个愚蠢的问题,我很抱歉,我自己不是程序员,我一直在从互联网上找到的位中拼凑出一个宏,我只剩下几行代码我根本无法得到答案。
我已经完成了我想让宏做的所有事情,除了条件格式位。问题是我希望它将格式(绿色单元格)应用于大于我当前所在的单元格上方 4 行的单元格值的单元格,然后将不同的格式(红色单元格)应用于值低于的单元格无论同一个单元格的值是多少(上面 4 行),但这次我需要该值为负数。
问题是我不知道如何告诉宏查找我所在的单元格上方 4 行的值,并且一旦完成,如何告诉宏更改符号单元格(乘以-1)
这是我遇到麻烦的一段代码。
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
Formula1:
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16752384
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13561798
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _
Formula1:
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
如您所见,我将 Formula1: 留空,这就是我想告诉宏查找我所在的单元格上方四个单元格的值
下一个公式1:空的需要查找上面四个单元格的值,然后乘以-1或将值更改为负数。
我希望你能在这里帮助我。 (对不起,英语邋遢和拼写不佳,不是我的母语)
【问题讨论】: