Array Formula

vmjan02

Well-known Member
Joined
Aug 15, 2012
Messages
1,132
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
Hi,

I have this code and its not working on VBA, but applied with Ctrl+Shift+enter manual its works.
Code:
With Worksheets("Sheet2") 'Rank
    With .Range("G5:G" & .Range("A" & .Rows.Count).End(xlUp).Row)
        .FormulaArray = "=IF(E5="""","""",COUNTIF($E$5:$E$8000,"">""&E5)+SUM(IF(E5=$E$5:E5,1,0)))" --- Same is not working
        .Value = .Value
    End With
End With
 
Last edited by a moderator:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi,

You could test :

Code:
.FormulaArray = _
        "=IF(R[-94]C[3]="""""""","""""""",COUNTIF(R5C5:R8000C5,"""">""""&R[-94]C[3])+SUM(IF(R[-94]C[3]=R5C5:R[-94]C[3],1,0)))"

HTH
 
Upvote 0
Your code is the equivalent of selecting all those cells and then array-entering the same formula into all of them; it is not the same as array entering the formula into G5 and then filling that down. What you need is:

Code:
With Worksheets("Sheet2") 'Rank
    .Range("G5").FormulaArray = "=IF(E5="""","""",COUNTIF($E$5:$E$8000,"">""&E5)+SUM(IF(E5=$E$5:E5,1,0)))"
    With .Range("G5:G" & .Range("A" & .Rows.Count).End(xlUp).Row)
        .FillDown
        .Value2 = .Value2
    End With
End With
 
Upvote 0
ops Rory, thanks I missed the part as need to enter the array formula first and then fill down. Thank a
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

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