Arrays Arrayformula显示错误:无法设置range类的formulaarray属性
我知道下面的Arrays Arrayformula显示错误:无法设置range类的formulaarray属性,arrays,excel,runtime-error,vba,Arrays,Excel,Runtime Error,Vba,我知道下面的FormulaArray是一条很长的线。但我不知道如何解决这个问题,因为它显示了运行时错误“1004”:无法设置Range类的FormulaArray属性 Private Sub CommandButton2_Click() Dim x As Variant Dim y As Variant Workbooks.Open (TextBox3.Text) x = Split(TextBox2.Value, Application.PathSeparator) y = Split(T
FormulaArray
是一条很长的线。但我不知道如何解决这个问题,因为它显示了运行时错误“1004”:无法设置Range类的FormulaArray属性
Private Sub CommandButton2_Click()
Dim x As Variant
Dim y As Variant
Workbooks.Open (TextBox3.Text)
x = Split(TextBox2.Value, Application.PathSeparator)
y = Split(TextBox3.Value, Application.PathSeparator)
Workbooks(x(UBound(x))).Sheets("KomponentenohneDuplikate").Activate
Workbooks(x(UBound(x))).Sheets("KomponentenohneDuplikate").Range("y5").FormulaArray = "=iferror(INDEX('[" & y(UBound(y)) & "]Regelung&Partno'!C1:C10,MATCH(1,('[" & y(UBound(y)) & "]Regelung&Partno'!C5=RC[-24])*('[" & y(UBound(y)) & "]Regelung&Partno'!C9=""DC""),0),10),""-"")"
With Workbooks(x(UBound(x))).Sheets("KomponentenohneDuplikate").Range("y5:y3263")
.FillDown
.Value = .Value
End With
如果我写的公式中没有'IFError()',那么它就可以工作了。这是下面给出的代码
Workbooks(x(UBound(x))).Sheets("KomponentenohneDuplikate").Range("y5").FormulaArray = "=INDEX('[" & y(UBound(y)) & "]Regelung&Partno'!C1:C10,MATCH(1,('[" & y(UBound(y)) & "]Regelung&Partno'!C5=RC[-24])*('[" & y(UBound(y)) & "]Regelung&Partno'!C9=""DC""),0),10)"
但我的公式的问题是,当在工作表“[”&y(UBound(y))&“]Regelung&Partno”中未找到匹配项时,它返回“#N/A”错误。所以我想用IfError()
函数添加公式。但它不起作用
请帮我解决这个问题。你好,我找到了问题的答案。我已经通过.Replace
功能搜索了internet并获得了正确的解决方案
Dim FormulaPart1 As String
Dim FormulaPart2 As String
Dim FormulaPart3 As String
Dim origRS As Long
origRS = Application.ReferenceStyle
Application.ReferenceStyle = xlR1C1
FormulaPart1 = "=IFERROR(""Part2"",""-"")"
FormulaPart2 = "INDEX('[" & y(UBound(y)) & "]Regelung&Partno'!C1:C10,""Part3"",10)"
FormulaPart3 = "MATCH(1,('[" & y(UBound(y)) & "]Regelung&Partno'!C5=RC[-25])*('[" & y(UBound(y)) & "]Regelung&Partno'!C9=""Diverse""),0)"
With Workbooks(x(UBound(x))).Worksheets("KomponentenohneDuplikate").Range("z5")
.FormulaArray = FormulaPart1
.Replace what:="""Part2""", replacement:=FormulaPart2, lookat:=xlPart
.Replace what:="""Part3""", replacement:=FormulaPart3, lookat:=xlPart
End With
Application.ReferenceStyle = origRS
朋友们好,在同一个FormulAarray
中,我使用了函数IFNA()
。现在可以了。但执行缓慢。我想将文件1(工作簿(x(UBound(x)).Sheets(“KomponentenohneDuplikate”)
)中的3259个数据与文件2中的约900.000个数据(“[”&y(UBound(y))&“]Regelung&Partno”
)进行比较。有没有办法更快地使用这个公式?但我的下一个类似公式仍然不起作用。我使用了.Replace
方法。但同样显示出同样的错误。Dim FormulaPart1作为字符串Dim FormulaPart2作为字符串FormulaPart1=“=ifna(索引(“[”&y(UBound(y))和“]Regelung&Partno”!C1:C10,part2,0),10),“-”)“FormulaPart2=“=匹配(1),(“[”&y(UBound(y))和“]Regelung&Partno”!C5=RC[-25])*(“[”&y(UBound(y))和“]Regelung&Partno”!C9=“”)和工作手册(x)(工作表)(“Komponenternohneduplikate”).Range(“z5”).FormulaArray=FormulaPart1。将“part2”、FormulaPart2、xlPart结尾替换为