Assign value to array element and use ARRAYTOTEXT function

gifariz

Board Regular
Joined
May 2, 2021
Messages
128
Office Version
  1. 365
Platform
  1. Windows
Suppose I have A = {1;2;3;4;5}
I want to replace i-th element to value x. If i=3, x=9, then B = {1;2;9;4;5}
Now I make custom function to do this assignment: =LAMBDA(array,i,val,VSTACK(INDEX(array,SEQUENCE(i-1)),val,INDEX(array,SEQUENCE(ROWS(array)-i,,i+1))))
But when I use it with ARRAYTOTEXT function, it gives incorrect result: C=ARRAYTOTEXT(Assign(A,3,9),1)={1;9;4}
It seems to have something to do with VSTACK that ARRAYTOTEXT recognize only VSTACK output's first value.
How do I solve this? Is there other way to do value assignment to an array that compatible with arraytotext function? Thanks
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Nevermind, I simplify the assignment function with:
Assign=LAMBDA(array,i,val,IF(SEQUENCE(ROWS(array))=i,val,array)))
and it works with ARRAYTOTEXT function
 
Upvote 0
Solution

Forum statistics

Threads
1,226,462
Messages
6,191,177
Members
453,644
Latest member
karlpravin

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