我正在努力使用数组公式(通过VBA)。基本上在我的功能中,我在一个表格中添加了一个列'然后为该列提供数组公式。我的数组公式超过255个字符。我在这里找到了一个解决方案Entering Long Array Formulas in VBA,但它对我不起作用。以下是我的代码。如果有人可以提供帮助,我将非常感激。感谢。
Set myNewColDC = Worksheets("DE").ListObjects("Table1").ListColumns.Add(Position:=(Worksheets("DE").ListObjects("Table1").ListColumns.Count - 2))
myNewColDC.Name = ThemeCleanedColHeader & " DC"
Dim theFormulaPart1 As String
Dim theFormulaPart2 As String
Dim theFormulaPart3 As String
theFormulaPart1 = "=AND(NOT(OR(SUMIF(Lst_Indic_" & ThemeCleaned & ",Lst_Indic_" & ThemeCleaned & ",OFFSET(I12,0,0,1,nbcol" & ThemeCleaned & "))>1)),AND(IF(COUNTIFS(OFFSET(I12,0,0,1,nbcol" & ThemeCleaned & "),""?"",Lst_Indic_" & ThemeCleaned & "," & _
"X_X_X()"
theFormulaPart2 = "Lst_Indic_" & ThemeCleaned & ")=0,COUNTIF(Lst_Indic_" & ThemeCleaned & ",Lst_Indic_" & ThemeCleaned & "),COUNTIFS(OFFSET(I12,0,0,1,nbcol" & ThemeCleaned & "),""?""," & _
"Y_Y_Y()"
theFormulaPart3 = "Lst_Indic_" & ThemeCleaned & ",Lst_Indic_" & ThemeCleaned & "))=COUNTIF(Lst_Indic_" & ThemeCleaned & ",Lst_Indic_" & ThemeCleaned & ")))*1"
With ActiveSheet.Range("Table1[" & ThemeCleanedColHeader & " DC]")
.Formula = theFormulaPart1
.Replace What:="X_X_X()", _
Replacement:=theFormulaPart2
.Replace What:="Y_Y_Y()", _
Replacement:=theFormulaPart3
End With
马立克