Array Formula not applying to each cell in column

TiredAnalyst

New Member
Joined
Feb 18, 2021
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
Hi,

First step into the world of VBA code. Getting there, although stuck on this.

I have an Array Formula that is not applying the way I need it to. Code is this:

Range("P2:P" & Cells(Rows.Count, "C").End(xlUp).Row).FormulaArray = "=IFNA(INDEX(Sheet2!$C$2:$C$43,MATCH(TRUE,ISNUMBER(SEARCH(Sheet2!$B$2:$B$43,D2)),0)),Apples)"

The formula runs down the column of around 100k lines but keeps checking against the cell in D2. I need it to check against the cell in column D relevant to the row. i.e. check D100 in row 100. The formula works as when I type it myself and make it an array formula I get the result I need. Thinking this is just my ignorance of VBA showing. Any advice as to what I'm doing wrong is appreciated.

Thanks
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Not something that I've had cause to do but I believe that you need to enter the formula into a single cell, then fill down.
VBA Code:
Range("P2").FormulaArray = "=IFNA(INDEX(Sheet2!$C$2:$C$43,MATCH(TRUE,ISNUMBER(SEARCH(Sheet2!$B$2:$B$43,D2)),0)),Apples)"
Range("P2:P" & Cells(Rows.Count, "C").End(xlUp).Row).Filldown
 
Upvote 0
Solution
Not something that I've had cause to do but I believe that you need to enter the formula into a single cell, then fill down.
VBA Code:
Range("P2").FormulaArray = "=IFNA(INDEX(Sheet2!$C$2:$C$43,MATCH(TRUE,ISNUMBER(SEARCH(Sheet2!$B$2:$B$43,D2)),0)),Apples)"
Range("P2:P" & Cells(Rows.Count, "C").End(xlUp).Row).Filldown
So simple!

Thanks very much
 
Upvote 0

Forum statistics

Threads
1,214,866
Messages
6,121,996
Members
449,060
Latest member
mtsheetz

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