VBA Run time error 1004: Unable to set the formulaarray property of the range class

后端 未结 1 2031
天涯浪人
天涯浪人 2021-01-26 14:16

VBA Run time error 1004: Unable to set the formulaarray property of the range class

I\'ve followed Dick Kusleika\'s advice in this link, but can\'t get the following arr

相关标签:
1条回答
  • 2021-01-26 15:05

    As I mentioned in the comments, it's just the length of the first part of the formula. I suggest you simplify further:

    Public Sub Configuration()
    
    Dim theFormulaPart1 As String
    
    Dim theFormulaPart2 As String
    
    Dim theFormulaPart3 As String
    
    theFormulaPart1 = "=IF(ISODD(B2),X_X_X1(),X_X_X())"
    theFormulaPart3 = "IFERROR(INDEX(Race1Grid,MATCH(C2&I2&""Q3""," & _
                    "QualRace1ID&QualDriver&QSession,0)),IFERROR(INDEX(Race1Grid" & _
                    ",MATCH(C2&I2&""Q2"",QualRace1ID&QualDriver&QSession,0)),INDEX" & _
                    "(Race1Grid,MATCH(C2&I2,QualRace1ID&QualDriver,0)))),"
    theFormulaPart2 = "IFERROR(INDEX(Race2Grid,MATCH(C2&I2&""Q3"",QualRace2ID&" & _
                    "QualDriver&QSession,0)),IFERROR(INDEX(Race2Grid,MATCH(C2&" & _
                    "I2&""Q2"",QualRace2ID&QualDriver&QSession,0)),INDEX(" & _
                        "Race2Grid,MATCH(C2&I2,QualRace2ID&QualDriver,0)))))"
    
        With ActiveSheet.Range("V2")
            .FormulaArray = theFormulaPart1
            .Replace "X_X_X())", theFormulaPart2
            .Replace "X_X_X1()", theFormulaPart3
        End With
    
    End Sub
    
    0 讨论(0)
提交回复
热议问题