if语句没有使用vba代码的else,给我一个语法错误

时间:2016-08-25 22:55:55

标签: vba if-statement syntax-error

Dim a As Long
a = range("A617:A737").Copy
s = range("A739:A" & EndLine + 2).PasteSpecial

Dim FinalLine As Long
FinalLine = Cells(Rows.Count, "A").End(xlUp).Row
range("B739").AutoFill Destination:=range("B739:B" & FinalLine - 2)

Cells(FinalLine + 10, 2).Formula = "= 5"

Cells("B" & FinalLine + 3).FormulaArray = _
 "= Min(If(B739:B" & FinalLine - 2 = FinalLine + 10 & " , A$739:A$" & EndLine + 2))"

错误是在10之后突出显示逗号。

2 个答案:

答案 0 :(得分:1)

Cells(FinalLine + 3, "B").FormulaArray = _
"= MIN(IF(B739:B" & (FinalLine - 2) & "=5 , A$739:A$" & (EndLine + 2) & ", """"))"

答案 1 :(得分:0)

更正后的代码......

 Cells( FinalLine + 3,"B").FormulaArray = "= Min(If(B739:B" & FinalLine - 2 = FinalLine + 10 & " , A$739:A$" & EndLine + 2 & ", """"))"