我的数组公式太长了所以我试图使用替换方法将此公式放入工作表中,但是当我运行代码时,我在第一个替换行上遇到类型不匹配错误。不知道是什么原因引起了这个问题:
Dim X0 As String
Dim X1 As String
Dim X2 As String
X0 = "=IF(COUNTIFS(R2C1:R5000C1,RC[-21],R2C20:R5000C20,RC[-2])>1,RC[-16]-INDEX(Cash!R2C41:R5000C41,MATCH(SMALL(IF(Cash!R2C40:R5000C40=RC[-21],ABS(Cash!R2C41:R5000C41-RC[-16])),1),IF(Cash!R2C40:R5000C40=RC[-21],ABS(Cash!R2C41:R5000C41-RC[-16])),0)),""X1"")"
X1 = "=IF(VLOOKUP(RC[-21],Cash!R2C42:R5000C59,18,0)=1,RC[-16]-VLOOKUP(RC[-21],Cash!R2C40:R5000C41,2,0),IF(AND(VLOOKUP(Deposits!RC[-21],Cash!R2C42:R5000C61,18,0)>1,VLOOKUP(Deposits!RC[-21],Cash!R2C42:R5000C61,18,0)<>""""),RC[-16]-VLOOKUP(RC[-21],Cash!R2C42:R5000C61,8,0),VLOOKUP(Deposits!RC[-21],Cash!R2C42:R5000C61,20,0)))"
X2 = "=IF(RC[-11]>0,IF(OR(RC[-2]=""Mix"",RC[-2]=""Possible Mix - Review Date""),""X0"",IF(Deposits!RC[-2]=""Non-Cash Transaction"",Deposits!RC[-16],"""")),"""")"
With ActiveSheet.Range("V2")
.FormulaArray = X2
.Replace """X0""", X0
.Replace """X1"")", X1
End With
A1
Dim X0 As String
Dim X1 As String
Dim X2 As String
Dim X3 As String
X2 = "=IF(K2>0,IF(OR(T2=""Mix"",T2=""Possible Mix - Review Date""),""X0"",IF(Deposits!T2=""Non-Cash Transaction"",Deposits!F2,"""")),"""")"
X0 = "IF(COUNTIFS($A$2:$A$5000,A2,$T$2:$T$5000,T2)>1,F2-INDEX(Cash!$AO$2:$AO$5000,MATCH(SMALL(IF(Cash!$AN$2:$AN$5000=A2,ABS(Cash!$AO$2:$AO$5000-F2)),1),IF(Cash!$AN$2:$AN$5000=A2,ABS(Cash!$AO$2:$AO$5000-F2)),0)),""X1"")"
X1 = "IF(VLOOKUP(A2,Cash!$AP$2:$BG$5000,18,0)=1,F2-VLOOKUP(A2,Cash!$AN$2:$AO$5000,2,0),""X3"")"
X3 = "IF(AND(VLOOKUP(Deposits!A2,Cash!$AP$2:$BI$5000,18,0)>1,VLOOKUP(Deposits!A2,Cash!$AP$2:$BI$5000,18,0)<>""""),F2-VLOOKUP(A2,Cash!$AP$2:$BI$5000,8,0),VLOOKUP(Deposits!A2,Cash!$AP$2:$BI$5000,20,0))"
With ActiveSheet.Range("V2")
.FormulaArray = X2
.Replace """X0""", X0, xlPart
.Replace """X1"")", X1, xlPart
.Replace """X3"")", X3, xlPart
End With