Variable .FormulaArray

helpexcel

Well-known Member
Joined
Oct 21, 2009
Messages
656
I'm using code to place this formula in the column A of a spreadsheet. Usually the code will update itself for each row, however this formula remains the same for every row. Any ideas why?

Range("A3:A" & LastRow).FormulaArray = "=Index(Data1,Match(1,(Data2=$G3)*(Data3=$T3)*(Data4=$L3)*(Data5=$K3)*(Data6<>Worksheet!$D$4)*(Data6<>Worksheet!$D$5),0))"

Thanks!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
I'm trying this on another array but i'm getting an error. It works if I manually enter it.

Any ideas on why I'm getting this error for this? Run-time error '1004': Unable to set the FormulaArray of the Range class

Range("C3").FormulaArray = "=IFERROR(VLOOKUP(INDEX(Data1,MATCH(1,(Data2=$G3)*(Data3=$T3)*(Data4=$L3)*(Data5=$K3)*(Data6=Worksheet!$D$4),0)),DataField,1,0),"")"
 
Upvote 0
As a minimum,

Code:
[COLOR="#FF0000"]...DataFiel d[/COLOR],1,0),[COLOR="#00FF00"]""""[/COLOR])"

... but that red part looks sketchy.
 
Upvote 0
More generally, you might try assigning the formula to a string variable and printing it to the Immediate window. If it's correct, you can copy it from there and paste it into the cell. If it doesn't work, fix it. Then you can do

Code:
myCell.FormulaArray = myString

When you put it directly into the cell, you're flying blind.
 
Upvote 0
Thoughts
1.You should double the quotes
Range("C3").FormulaArray = "=IFERROR(VLOOKUP(INDEX(Data1,MATCH(1,(Data2=$G3)*(Data3=$T3)*(Data4=$L3)*(Data5=$K3)*(Data6=Worksheet!$D$4),0)),DataFiel d,1,0),"""")"
2. VLOOKUP(INDEX(...), DataField,1,0) returns the same value, if found, returned by INDEX (???) - it seems superfluous.
3. Be sure all the named ranges, Data1, Data2 etc, have the same size
4.Check
The result of INDEX(Data1, MATCH(1,....,0))
Is it present in DataField?

M.
 
Last edited:
Upvote 0
Thanks!! the Red text is my error copying it over. I forgot about the extra "" when using .Formula
 
Upvote 0

Forum statistics

Threads
1,215,532
Messages
6,125,367
Members
449,221
Latest member
chriscavsib

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