VBA error, Unable to set the FormulaArray property of the Range class

anto2696

New Member
Joined
Apr 7, 2020
Messages
1
Office Version
  1. 2016
Hello, I have tried to apply this formula from a macro but it indicates an error due to the number of characters, I have tried to separate it but it does not work well. Please request your help. Thanks a lot

Fórmula:

Sub Sinumbral()

Range("C6").Select
Selection.FormulaArray = _
"= + IF (Macro! R [43] C [-1] =" "N / A" ", SUM (IFERROR (1 / COUNTIF ('Prueba 1'! RC [-2]: R [1048570] C [ -2], 'Prueba 1'! RC [-2]: R [1048570] C [-2]), 0)), "& Chr (10) y" IF (Macro! R [43] C [-1] ] = "" Mayor a "", SUM (IFERROR (1 / COUNTIF ('Info adic Prueba 1'! RC [-2]: R [1048570] C [-2], 'Info adic Prueba 1'! RC [- 2]: R [1048570] C [-2]), 0)), "" "")) "

End Sub

To be able to separate it I have done the following:


Sub

Dim formulaPart As String
formulaPart = " SUM(IFERROR(1/COUNTIF('Prueba 1'!RC[-2]:R[1048570]C[-2], " & _
" 'Prueba 1'!RC[-2]:R[1048570]C[-2]),0))," & Chr(10) & "IF(Macro!R[43]C[-1]=""Mayor a "", " & _
" SUM(IFERROR(1/COUNTIF('Info adic Prueba 1'!RC[-2]:R[1048570]C[-2],'Info adic Prueba 1'!RC[-2]:R[1048570]C[-2]),0)),""""))"

With Range("C6")
.FormulaArray = "=+IF(Macro!R[43]C[-1]=""N/A"", X_X_X)"
.Replace "X_X_X", formulaPart, xlPart
End With

End Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Try using the A1 reference style for your replacement string in formulaPart, instead of the R1C1 reference style...
 
Upvote 0

Forum statistics

Threads
1,214,896
Messages
6,122,132
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top