ERROR 1004 when trying to use FormulaArray. Replace trick does not work

后端 未结 2 1012
傲寒
傲寒 2020-12-04 02:58

BACKGROUND: I got a cool Array Formula and it works perfect in Excel. Now I\'m trying to do the same formula, but with VBA. So I typed the Array Formula in

2条回答
  •  执念已碎
    2020-12-04 03:46

    I'd bet your Excel is not set to use R1C1 referencing, so the replace won't work as you're trying to put an R1C1 referenced string into an A1 style formula. Try using:

    Application.ReferenceStyle = xlR1C1
    With ActiveSheet.Range("F2")
            .FormulaArray = theFormulaPart1
            .Replace MiReemplazo, theFormulaPart2
        End With
    Application.ReferenceStyle = xlA1
    

提交回复
热议问题