Range("N2").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-4]="""","""",IF(RC[-2]=""NA"",""N/A"",IF(RC[-2]=""N/A"",""N/A"",IF(RC[-2]>=RC[-4],""Met"",""Not Met""))))"
Selection.AutoFill Destination:=Range(Cells(2, 14), Cells(a, 14))
代码目前正在运行,但我想添加一些东西。假设添加条件
(IF G2 = "AR17 - Standard Report" or "IT18 - Standard Report" or "CSYT - Standard Report", then the calculation should be (RC[-2]<=RC[-4],""Met"",""Not Met and if not, the calculation should be RC[-2]>=RC[-4],""Met"",""Not Met)
使事情更清楚。我想反转所有具有“AR17 - 标准报告”,“IT18 - 标准报告”和“CSYT - 标准报告”的行的当前公式。我有数以千计的数据,所以我希望所有具有这些值的行具有相反的公式。我希望有一个人可以帮助我。我对VBA很新。
编辑:现在这是我的代码。没有错误但是,G列中的那些指定文本的公式没有变化。
Range("N2").Select
If Not IsError(Application.Match(Range("G2"), Array("sample1", "sample2", "sample3"), False)) Then
'First statement
ActiveCell.FormulaR1C1 = "=IF(RC[-2]<=RC[-4],""Met"",""Not Met"")"
Selection.AutoFill Destination:=Range(Cells(2, 14), Cells(a, 14))
Else
'Second
ActiveCell.FormulaR1C1 = _
"=IF(RC[-4]="""","""",IF(RC[-2]=""NA"",""N/A"",IF(RC[-2]=""N/A"",""N/A"",IF(RC[-2]>=RC[-4],""Met"",""Not Met""))))"
Selection.AutoFill Destination:=Range(Cells(2, 14), Cells(a, 14))
End If
答案 0 :(得分:0)
我家里没有Excel,但你可以试试这个:
head
您可以通过查看宏录制内容来调整公式。