APUZZLE

=APUZZLE(a,b,r1w,r2w,c1l,c2l)

a
array, target
b
array, replacement values
r1w
1st value row index of array "a"
r2w
2nd value row index of array "a"
c1l
1st value clm index of array "a"
c2l
2nd value clm index of array "a"

Replaces selected areas of an array "a" with other array "b" values , from left to right , top to bottom. !! NEW !! MAKEARRAY , SCAN

Xlambda

Well-known Member
Joined
Mar 8, 2021
Messages
860
Office Version
  1. 365
Platform
  1. Windows
APUZZLE replaces selected areas of an array "a" with other array "b" values , from left to right , top to bottom. !! NEW !! MAKEARRAY , SCAN . Calls AFLAT
Excel Formula:
=LAMBDA(a,b,r1w,r2w,c1l,c2l,
    LET(fb,AFLAT(b,1),r,ROWS(a),c,COLUMNS(a),x,MEDIAN(1,IF(r1w,r1w,1),r),y,MEDIAN(1,IF(r2w,r2w,r),r),z,MEDIAN(1,IF(c1l,c1l,1),c),w,MEDIAN(1,IF(c2l,c2l,c),c),
      m,MAKEARRAY(r,c,LAMBDA(r,c,IF(x>y,(r>=x)+(r<=y),(r>=x)*(r<=y))*IF(z>w,(c>=z)+(c<=w),(c>=z)*(c<=w)))),
      s,IFERROR(INDEX(fb,SCAN(0,m,LAMBDA(v,a,v+a))),""),
      IF(m,s,IF(a="","",a))
    )
)
LAMBDA 1.1.1.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACAD
1APUZZLE replaces areas of an array "a" with other array "b" values , from left to right , top to bottom
2r1w,r2w,c1l,c2l are required arguments that help us select only certain areas of source array to be replaced. Data outside area selected will remain unchanged
3r1w,r2w,c1l,c2l, functionality
4a.) if arg. are ignored or out of range formula will asign this value r1w=1,r2w=rows(a),c2l=1,c2l=clms(a), this means the whole array will be replaced
5Note:If an argument is ignored we still have to write the commas, for omitted arguments we don't
6Default value for an "ignored" required argument is a blank (a blank is a 0 and a null string on the same time)
7I have used"can be ignored"arguments, and not omitted, because on most case scenarios, we do have to select some valuesb
8b.) if values r1w,r2w not ignored, formula will select all the rows (rw) that follow this condition: rw>=r1w and rw<=r2w EF
9c.) if values c1l,c2l not ignored, formula will select all the clms (cl) that follow this condition: cl>=c1l and cl<=c2lGH
10JKL
11Examples of r1w,r2w,c1l,c2l various scenarios:
12
132,4,2,4 (arguments sequence)2,4,4,15,2,5,25,2,2,4
14a>=2cl<=4<=1cl>=4<=2cl>=5>=2cl<=4
1512345123451234512345
16>=2678910>=2678910<=2678910<=2678910
17rw1112131415rw1112131415rw1112131415rw1112131415
18<=41617181920<=4161718192016171819201617181920
1921222324252122232425>=52122232425>=52122232425
202627282930262728293026272829302627282930
21
22=APUZZLE(B15#,$W$8:$Y$10,2,4,2,4)=APUZZLE(I15:M20,$W$8:$Y$10,2,4,4,1)=APUZZLE(P15:T20,$W$8:$Y$10,5,2,5,2)=APUZZLE(W15:AA20,$W$8:$Y$10,5,2,2,4)
231234512345 E34F1EF5
246EF1078EFGH896GH10
2511GH15G1213H11121314151112131415
2616JKL20J1718KL16171819201617181920
2721222324252122232425JK2324L21JKL25
282627282930262728293028292630
29
30ball rows, clms 2,4: ,,2,4all clms rws 6,1: 6,1,,,3,3,only corners: 6,1,5,1
31A=APUZZLE(B15#,B31:B48,,,2,4)=APUZZLE(B15#,B31:B48,6,1,,)=APUZZLE(B15#,B31:B48,,3,3,)=APUZZLE(B15#,B31:B48,6,1,5,1)
32B1ABC5ABCDE12ABCA234B
33C6DEF1067891067DEF678910
34D11GHI1511121314151112GHI1112131415
35E16JKL20161718192016171819201617181920
36F21MNO25212223242521222324252122232425
37G26PQR30FGHIJ2627282930C272829D
38H
39Imore arrays, random areas, nested formula needed
40Jb1=APUZZLE(APUZZLE(B15#,D41:H41,,2,4,),D43:F45,4,,,2)
41KABCDE123AB
42Lb2678CDresize same array , 6x5 to a 3x10
43Mabc1112131415=APUZZLE(REPT("",SEQUENCE(3,10)),B15#,,,,)
44Ndefab18192012345678910
45Oghicd23242511121314151617181920
46Pef28293021222324252627282930
47Q
APUZZLE post
Cell Formulas
RangeFormula
W8W8=""
B15:F20B15=SEQUENCE(6,5)
B22,I22,P22,W22,R43,J40,V31,P31,J31,D31B22=FORMULATEXT(B23)
B23:F28B23=APUZZLE(B15#,$W$8:$Y$10,2,4,2,4)
I23:M28I23=APUZZLE(I15:M20,$W$8:$Y$10,2,4,4,1)
P23:T28P23=APUZZLE(P15:T20,$W$8:$Y$10,5,2,5,2)
W23:AA28W23=APUZZLE(W15:AA20,$W$8:$Y$10,5,2,2,4)
D32:H37D32=APUZZLE(B15#,B31:B48,,,2,4)
J32:N37J32=APUZZLE(B15#,B31:B48,6,1,,)
P32:T37P32=APUZZLE(B15#,B31:B48,,3,3,)
V32:Z37V32=APUZZLE(B15#,B31:B48,6,1,5,1)
J41:N46J41=APUZZLE(APUZZLE(B15#,D41:H41,,2,4,),D43:F45,4,,,2)
R44:AA46R44=APUZZLE(REPT("",SEQUENCE(3,10)),B15#,,,,)
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

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