0
내 .FormulaArray
을 .Replace
을 사용하여 길게 쓰는 방법. 도와주세요Excel VBA : 내 장거리 FormulaArray 코드를 .replace로 다시 작성하는 방법
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
의 수식을 대체하지 않습니다. 희미한 FormulaPart1는 문자열 으로 희미한 FormulaPart2는 문자열 으로 희미한 FormulaPart3는
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으로 어떻게이 문제를 해결하는 방법 도와주세요.
귀하의 공식이 작동하지 않을 수 있도록 1 열 범위의 10 열을 반환하려고 시도 할를 사용하여 정확한 공식이다. 이 배열 수식 대신 LOOKUP을 거의 사용할 수 있습니다. 단, 여러 일치 항목이있을 수 있고 마지막 결과보다 첫 번째 결과가 필요한 경우가 아니면 예외입니다. – Rory