if(row(),formula) Evaluate construct returns 1st array value only

Jon von der Heyden

MrExcel MVP, Moderator
Joined
Apr 6, 2004
Messages
10,912
Office Version
  1. 365
Platform
  1. Windows
Hi All

Say I have the following:

Code:
Selection.Value = "if(row(),vlookup('Test'!$A$2:$A$10,Test!$D$2:$E$4,2,false))"

Although the match value is an array, I would have assumed the result to return an array.

Selection is same dimension (9 rows, 1 column).

I have also attempted the same using index alternative to if(row()... And I have tried an INDEX MATCH approach, instead of VLOOKUP.

Any idea why it isn't behaving as expected?

Edit: Some debugging info if it helps... The result is definitely an array result i.e. Variant(1 to 9, 1 to 1). Every value in the array is the result of the first vlookup, i.e. vlookup('Test'!A2,'Test'!D2:E4,2,false).

Regards
Jon
 
Last edited:

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I assume there is in fact an Evaluate in the code and an address passed to ROW()?

Assuming so, you need a little extra work to force the passing of the array of entries - for example:

Code:
Selection.Value = Evaluate("if(row(A2:A10),vlookup(INDEX('Test'!$A$2:$A$10,N(IF(1,ROW($A$2:$A$10)-min(row($A$2:$A$10))+1))),Test!$D$2:$E$4,2,false))")
 
Last edited:
Upvote 0
I assume there is in fact an Evaluate in the code and an address passed to ROW()?

Yes, sorry just me being me, and copying one of my lame attempts from the immediate window.

Assuming so, you need a little extra work to force the passing of the array of entries - for example:

Code:
Selection.Value = Evaluate("if(row(A2:A10),vlookup(INDEX('Test'!$A$2:$A$10,N(IF(1,ROW($A$2:$A$10)-min(row($A$2:$A$10))+1))),Test!$D$2:$E$4,2,false))")

Epic! Works a treat! Thanks Rory.
 
Upvote 0
Ugh! I went down the formula route after all. This (fantastic) solution increases the character count so much I have instances exceeding 255 chars. I tried creating holding names for the instances where they are needed but then it reverts back to the 1st array item value.
 
Upvote 0

Forum statistics

Threads
1,223,902
Messages
6,175,278
Members
452,629
Latest member
SahilPolekar

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