AINSERT

=AINSERT(a,d,p,i)

a
array
d
any string delimiter
p
integer , pace width
i
integer, index starting point, first delimiter will be placed in the i th position , or just after (i-1)th character, so for i ignored or i<=2, insert will start after 1st character

AINSERT, array insert, inserts any string delimiter "d" between characters of an array "a" with a selectable pace "p" and selectable starting point "i".

Xlambda

Well-known Member
Joined
Mar 8, 2021
Messages
832
Office Version
  1. 365
Platform
  1. Windows
AINSERT !! recursive !! array insert, insert any string delimiter "d" between characters of an array "a" with a selectable pace "p" and selectable starting point "i".
Excel Formula:
=LAMBDA(a,d,p,i,
    LET(ld,LEN(d),k,MAX(p,1),j,MAX(k+1,i),n,MAX(LEN(a)),
       IF(n<(j-1),SUBSTITUTE(TRIM(SUBSTITUTE(a,d," "))," ",d),AINSERT(REPLACE(a,j,,d),d,k,j+2*(k+1)-k-1+ld-1))
    )
)
LAMBDA 6.0.xlsx
ABCDEFGHIJKLMNOPQR
1sample=AINSERT(A2:A4,"-",1,)
2qwertyuiop98765q-w-e-r-t-y-u-i-o-p-9-8-7-6-5
3asdfghjkl123a-s-d-f-g-h-j-k-l-1-2-3
4zxcvbnm123456z-x-c-v-b-n-m-1-2-3-4-5-6
5
6=AINSERT(A2:A4,"--",,)
7q--w--e--r--t--y--u--i--o--p--9--8--7--6--5
8a--s--d--f--g--h--j--k--l--1--2--3
9z--x--c--v--b--n--m--1--2--3--4--5--6
10extract values withASPLITextract only text values withAFILTER
11=AINSERT(A2:A4,"-",2,)=ASPLIT(C12:C14,"-")=AFILTER(D12#,-1,)
12qw-er-ty-ui-op-98-76-5qwertyuiop98765qwertyuiop
13as-df-gh-jk-l1-23asdfghjkl123asdfghjkl1
14zx-cv-bn-m1-23-45-6zxcvbnm123456zxcvbnm1
15
16=AINSERT(A2:A4,"--",3,)=ASPLIT(C17#,"--")extract only numeric values
17qwe--rty--uio--p98--765qwertyuiop98765=AFILTER(D12#,1,)
18asd--fgh--jkl--123asdfghjkl12398765
19zxc--vbn--m12--345--6zxcvbnm12345623
2023456
21i=5,inserting starts after 4th character
22=AINSERT(A2:A4,"///",3,5)=ASPLIT(C23#,"///")
23qwer///tyu///iop///987///65qwertyuiop98765
24asdf///ghj///kl1///23asdfghjkl123
25zxcv///bnm///123///456zxcvbnm123456
26
AINSERT post
Cell Formulas
RangeFormula
C1,C22:D22,M17,C16:D16,M11,C11:D11,C6C1=FORMULATEXT(C2)
C2:C4C2=AINSERT(A2:A4,"-",1,)
C7:C9C7=AINSERT(A2:A4,"--",,)
C12:C14C12=AINSERT(A2:A4,"-",2,)
D12:K14D12=ASPLIT(C12:C14,"-")
M12:Q14M12=AFILTER(D12#,-1,)
C17:C19C17=AINSERT(A2:A4,"--",3,)
D17:H19D17=ASPLIT(C17#,"--")
M18:O20M18=AFILTER(D12#,1,)
C23:C25C23=AINSERT(A2:A4,"///",3,5)
D23:H25D23=ASPLIT(C23#,"///")
Dynamic array formulas.
 
Last edited by a moderator:
Upvote 0
Note: The following Lambda functions are used in the sample mini-sheet above are explained in the following pages:
ASPLIT
AFILTER
 
Thanks a lot!!! Normally I set the links myself in the description, but I did it only if the other functions are embedded or called by the one posted. I will do this in the future. Don't want to bother.
I use them to prove the versatility of using them in dif scenario. Thanks again!!!!!✌✌
 
No problem.

Since they are not native functions, anybody who copies the mini-sheet will have missing function errors if they don't know how to access the other custom functions, so it is always great to provide links for any custom functions used in the samples.

By the way, great work with the array functions!
 
Makes sense. In the minisheet above in cell H10 and Q10 I set them as links. Is ok like this or should be also in the main description area?

Thanks!! I really use them like a toolkit on daily basis.
 
In the minisheet above in cell H10 and Q10 I set them as links. Is ok like this or should be also in the main description area?
It is a good idea but honestly, if I didn't notice that then I doubt others will do. There are other clickable formula cells in the mini-sheet and I even didn't notice those links.
So, although this would work, I would still list them in the descriptions.
 
I will do both in the future!! Sorry for the trouble!! The whole ecosystem is amazing!! Thanks!!
 

Forum statistics

Threads
1,216,091
Messages
6,128,772
Members
449,468
Latest member
AGreen17

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