VBA to fill a range with an Array Formula

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,347
Office Version
  1. 365
Platform
  1. Windows
Is there a way to fill a range with an Array formula. I need the formula going into column R to be an Array

Code:
Sub Macro3()
'
' Macro3 Macro
'

'
    Range("Q3:Q11").FormulaR1C1 = _
        "=IF(AND(INDEX(C25,MATCH(RC15,C[7],0))=TRUE,COUNTA(R3C22:R230C22)=0),RC[-3],IF(AND(INDEX(C25,MATCH(RC15,C[7],0))=TRUE,COUNTIF(R3C22:R230C22,RC[-1])>0),RC[-3],""""))"
    Range("R3:R11").FormulaR1C1 = _
        "=IFERROR(INDEX(R2C17:R248C17,SMALL(IF(ISTEXT(R2C17:R248C17),ROW(R1C17:R247C17)), ROW(R[-1]C[-1]))),"""")"

End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Try
Code:
Sub Macro3()
'
' Macro3 Macro
'

'
    Range("Q3:Q11").FormulaR1C1 = _
        "=IF(AND(INDEX(C25,MATCH(RC15,C[7],0))=TRUE,COUNTA(R3C22:R230C22)=0),RC[-3],IF(AND(INDEX(C25,MATCH(RC15,C[7],0))=TRUE,COUNTIF(R3C22:R230C22,RC[-1])>0),RC[-3],""""))"
    Range("R3").FormulaArray = _
        "=IFERROR(INDEX(R2C17:R248C17,SMALL(IF(ISTEXT(R2C17:R248C17),ROW(R1C17:R247C17)), ROW(R[-1]C[-1]))),"""")"
   Range("R3:R11").Filldown
End Sub
 
Upvote 0
Fluff

That array formula is supposed to make a continuous list (no blanks). I am having a problem making that list. In the first half of the Code, its doing a copy and Past value. Taking the formulas out of the column because the Array formula doesn't see formulas or " "" " as blanks. So I thought I would take the formulas out by doing a paste value. Unfortunately, it didn't work. It thinks there is still values in those cells. If I go into the "Blanks" and hit delete, the Array works. How do I get those " "" " cells to be blank?
 
Last edited:
Upvote 0
How about
Code:
Sub Macro3()
'
' Macro3 Macro
'

'
    Range("Q3:Q11").FormulaR1C1 = _
        "=IF(AND(INDEX(C25,MATCH(RC15,C[7],0))=TRUE,COUNTA(R3C22:R230C22)=0),RC[-3],IF(AND(INDEX(C25,MATCH(RC15,C[7],0))=TRUE,COUNTIF(R3C22:R230C22,RC[-1])>0),RC[-3],""""))"
    Range("R3").FormulaArray = _
        "=IFERROR(INDEX(R2C17:R248C17,SMALL(IF((R2C17:R248C17<>""""),ROW(R1C17:R247C17)), ROW(R[-1]C[-1]))),"""")"
   Range("R3:R11").Filldown
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,021
Latest member
Mohamed Magdi Tawfiq Emam

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