2017-03-22 136 views
0

次のように私は知っていますFormulaArrayは長い行です。それは私が `IFERROR()」せずに式を記述する場合、それは動作しますRun-time error '1004': Unable to set the FormulaArray property of the Range classArrayformulaにエラーが表示されます。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 

を示しているのでしかし、私はこの問題を解決する方法がわかりません。これは以下のコードです。

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()関数で数式を追加したい。しかし、それは動作しません

私はこれを解決する方法を助けてください。

+0

こんにちは、同じ 'FormulAarray'では、私は関数' IFNA() 'を使いました。それは今働く。しかし、実行は遅かった。私は、ファイル2( ''["&y(UBound(y))]の~900.000までのファイル1( 'Workbooks(x(UBound(x))) & "] Regelung&Partno'')。この式をもっと速く動かす方法はありますか? –

+0

しかし、私の次の同様の数式はまだ動作していません。私は '.Replace'メソッドを使用しました。しかし、同じエラーが再び表示されます。 Dim FormulaPart1 As String Dim FormulaPart2 As String FormulaPart1 = "= ifna(INDEX( '["&y(UBound(y))& "] Regelung&Partno'!C1:C10、part2,0)、10) ( "["&y "(UBound(y))&"] ")"FormulaPart2 = "= MATCH(1、 ( "z5") ワークシート(x(U)))ワークシート( "KomponentenohneDuplikate")。.FormulaArray = FormulaPart1 。 "part2"、FormulaPart2、xlPartを置換する 最後に –

答えて

0

こんにちは私は私の問題の答えを見つけました。私はインターネットを検索し、.Replace機能で正しい解決策を得ました。

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 
関連する問題