0
.FormulaArray
を.Replace
を使用して書き直すにはどうすればいいですか?助けてくださいExcel VBA:.replaceで長い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("z5").FormulaArray = "=iferror(INDEX('[" & y(UBound(y)) & "]Regelung&Partno'!C1:C10,MATCH(1,('[" & y(UBound(y)) & "]Regelung&Partno'!C5=RC[-25])*('[" & y(UBound(y)) & "]Regelung&Partno'!C9=""Diverse""),0),10),""-"")"
With Workbooks(x(UBound(x))).Sheets("KomponentenohneDuplikate").Range("y5:y3263")
.FillDown
.Value = .Value
End With
私は次のコードを試しました。結果はPart2
と表示されます。プログラムはPart2
とPart3
の式を置き換えません。文字列 列 ロング
origRS = Application.ReferenceStyle
Application.ReferenceStyle = xlR1C1
FormulaPart1 = "=IFerror(""Part2"",""-"")"
FormulaPart2 = "INDEX('[" & y(UBound(y)) & "]Regelung&Partno'!C1:C10,""Part3"",0),10)"
FormulaPart3 = "MATCH(1,('[" & y(UBound(y)) & "]Regelung&Partno'!C5=RC[-25])*('[" & y(UBound(y)) & "]Regelung&Partno'!C9=""Diverse"")"
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
として暗いorigRSとして暗いFormulaPart3として暗いFormulaPart2として 点心FormulaPart1この問題を解決する方法を、私を助けてください。ここで
あなたの式は、仕事に行くされていないので、1列の範囲の10番目の列を返すようにしようとしているように見えます。この配列式の代わりにLOOKUPを使用することはほとんどできますが、複数の一致があり、最後の結果ではなく最初の結果が必要な場合を除きます。 – Rory