APP2H

APP2H(a1r,a2r,[i],[o])
a1r
array
a2r
array
[i]
optional,clm index 2nd array, i<0, only clms 1 to clms i, i>0, appends clms i to clms(a2r)
[o]
optional, offset argument, o<0, lifts 2nr array up "o" rows, o>0, lowers 2nd array "o" rows down

APPends 2 arrays Horizontally, 2nd array column index and offset functionality. !! NEW !! MAKEARRAY , SCAN

Xlambda

Well-known Member
Joined
Mar 8, 2021
Messages
860
Office Version
  1. 365
Platform
  1. Windows
APP2H APPends 2 arrays Horizontally, 2nd array column index and offset functionality. !! NEW !! MAKEARRAY
Excel Formula:
=LAMBDA(a1r,a2r,[i],[o],
    LET(a,IF(a1r="","",a1r),b,IF(a2r="","",a2r),c,ROWS(a),d,ROWS(b),e,COLUMNS(a),f,COLUMNS(b),j,IF(OR(ISOMITTED(i),i=0),1,MEDIAN(i,-f,f)),
      IFERROR(MAKEARRAY(MAX(IF(o<0,c-o,c),IF(o>0,d+o,d)),e+IF(j<0,-j,f-j+1),
        LAMBDA(r,c,LET(x,IF(o>=0,IF(c>e,IF(r>o,r-o,""),r),IF(c<=e,IF(r>-o,r+o,""),r)),y,IF(c>e,IF(j>0,c-e+j-1,c-e),c),IF(c<=e,INDEX(a,x,y),INDEX(b,x,y))))),"")
    )
)
LAMBDA 1.1.1.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXY
1"i" column index argument (for 2nd array, "a2r" (b in our examples))if array arguments are omitted, or contant arrays
2i omitted or 0 or 1, appends whole b to ai,o,omitted=APP2H(,C13:D15,2,1)
3i>0, appends only columns indexes >=i of b (from i to the right, including i)=APP2H(,C13:D15) i,2,o,1
4i<0, appends only column indexes <=abs(i) of b (from abs(i) to the left, including i) abb
5if abs(i)>colms(b) and i<0 i= -clms(b),so whole b is appended (from clms(b) to left)c
6if abs(i)>colms(b) and i>0 i=clms(b),so only last column of b is appended (from clms(b) to right)eff
7"o" offset argumenti,,o,1i,,o-1
8o=0 arrays will be top aligned=APP2H(C13:D15,{2;2},,1)=APP2H(C13:D15,"T",,-1)
9o>0 array b will offset "o" rows downab T
10o<0 array b will offset "o" rows upc2ab
11ef2c
12aef
13abo,omittedo, different values
14c
15efi,omittedi,omitted,o,-1
16b=APP2H(C13:D15,B17:E19)=APP2H(C13:D15,B17:E19,,-1)
171234ab1234 1234
18568c568ab568
199101112ef9101112c9101112
20ef
21
22i,3i,3i,3,o,1
23b=APP2H(C13:D15,B24:E26,3)=APP2H(C13:D15,B24:E26,3,1)
241234ab34ab
25568c8c34
269101112ef1112ef8
271112
28
29i,-3i,-3i-3,-2
30b=APP2H(C13:D15,B31:E33,-3)=APP2H(C13:D15,B17:E19,-3,-2)
311234ab123 123
32568c5656
339101112ef91011ab91011
34c
35ef
36
37i>0 and i>clms(b)=> i=4i,100i,10,o,2
38b=APP2H(C13:D15,B39:E41,100)=APP2H(C13:D15,B39:E41,10,2)
391234ab4ab
40568c8c
419101112ef12ef4
428
4312
44
45i<0,and abs(i)>clms(b)=> i=-4i,-100i,5,o,1
46b=APP2H(C13:D15,B47:E49,-100)=APP2H(INDEX(H47#,SEQUENCE(3),SEQUENCE(,4)),H47#,5,1)
471234ab1234ab12
48568c568c5634
499101112ef9101112ef9108
501112
51!! Offsetting same array !!
52
53
54i,o,omitted
55cd=APP2H(C56:E59,G56:J57)
56abc1234abc1234
57def5678def5678
58ghighi
59jkljkl
60
61i,3i,2,o,1
62d=APP2H(C56:E59,G63:J64,2,1)
631234abc
645678def234
65ghi678
66jkl
67
68i, -3i-3,o,2
69d=APP2H(C56:E59,G70:J71,-3,2)
701234abc
715678def
72ghi123
73jkl567
74
75
76
APP2H post
Cell Formulas
RangeFormula
U2,M69,M62,M55,Q46,H46,Q38,H38,Q30,H30,Q23,H23,Q16,H16,U8,Q3U2=FORMULATEXT(U3)
U3:V6U3=APP2H(,C13:D15,2,1)
Q4:S6Q4=APP2H(,C13:D15)
P8P8=FORMULATEXT(Q9)
Q9:S11Q9=APP2H(C13:D15,{2;2},,1)
U9:W12U9=APP2H(C13:D15,"T",,-1)
H17:M19H17=APP2H(C13:D15,B17:E19)
Q17:V20Q17=APP2H(C13:D15,B17:E19,,-1)
H24:K26H24=APP2H(C13:D15,B24:E26,3)
Q24:T27Q24=APP2H(C13:D15,B24:E26,3,1)
H31:L33H31=APP2H(C13:D15,B31:E33,-3)
Q31:U35Q31=APP2H(C13:D15,B17:E19,-3,-2)
H39:J41H39=APP2H(C13:D15,B39:E41,100)
Q39:S43Q39=APP2H(C13:D15,B39:E41,10,2)
H47:M49H47=APP2H(C13:D15,B47:E49,-100)
Q47:V50Q47=APP2H(INDEX(H47#,SEQUENCE(3),SEQUENCE(,4)),H47#,5,1)
M56:S59M56=APP2H(C56:E59,G56:J57)
M63:R66M63=APP2H(C56:E59,G63:J64,2,1)
M70:R73M70=APP2H(C56:E59,G70:J71,-3,2)
Dynamic array formulas.
 
Upvote 0
LAMBDA 1.1.1.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAE
1Corner arraysAll corners
2abb1b2b3b4
31234ABABEFiJMN
45678CDCDGHKLOP
59101112
613141516
7=AFILL(AFILL(APP2H(O3:P4,APP2H(B3#,X3:Y4,,4),,2),R3:S4,1,2,7,8),U3:V4,7,8,1,2)
8ABEF
9=APP2H(B3#,H3:I4,,-ROWS(H3:I4))=APP2H(B3#,H3:I4,,ROWS(B3#))CDGH
10 AB12341234
11CD56785678
12123491011129101112
1356781314151613141516
149101112ABiJMN
1513141516CDKLOP
16
17
18=APP2H(H3:I4,B3#,,ROWS(H3:I4))=APP2H(H3:I4,B3#,,-ROWS(B3#))=AFILL(AFILL(Q8#,AA21:AD24,3,6),AA27:AD30,,,3,6)
19AB 1234ABA1A2A3A4EF
20CD5678CDB1B2B3B4GHc1
211234910111211121234212211122122
2256781314151613145678232413142324
239101112AB15169101112252615162526
2413141516CD171813141516272817182728
25iJC1C2C3C4MN
26KLC5C6C7C8OPc2
27A1A2A3A4
28other functions on minisheetB1B2B3B4
29AFILL=APUZZLE(Q19#,AA33#,3,6,3,6)C1C2C3C4
30APUZZLEABA1A2A3A4EFC5C6C7C8
31CDB1B2B3B4GH
321112161514132122d
3313141211109232416151413
341516876525261211109
351718432127288765
36iJC1C2C3C4MN4321
37KLC5C6C7C8OP
38
APP2H post 2
Cell Formulas
RangeFormula
B3:E6B3=SEQUENCE(4,4)
M7M7=FORMULATEXT(Q8)
Q8:X15Q8=AFILL(AFILL(APP2H(O3:P4,APP2H(B3#,X3:Y4,,4),,2),R3:S4,1,2,7,8),U3:V4,7,8,1,2)
A9,H9,Q29,A18,H18A9=FORMULATEXT(A10)
A10:F15A10=APP2H(B3#,H3:I4,,-ROWS(H3:I4))
H10:M15H10=APP2H(B3#,H3:I4,,ROWS(B3#))
P18P18=FORMULATEXT(Q19)
A19:F24A19=APP2H(H3:I4,B3#,,ROWS(H3:I4))
H19:M24H19=APP2H(H3:I4,B3#,,-ROWS(B3#))
Q19:X26Q19=AFILL(AFILL(Q8#,AA21:AD24,3,6),AA27:AD30,,,3,6)
Q30:X37Q30=APUZZLE(Q19#,AA33#,3,6,3,6)
AA33:AD36AA33=SEQUENCE(4,4,16,-1)
Dynamic array formulas.
 
Introducing APPNHV(n,d) , the lambda that writes other lambda, a lambda for appending n arrays horizontally or vertically.
n: nr. arrays to be appended
d: direction, "h", horizontal; "v", vertical
Excel Formula:
=LAMBDA(n,d,
    IF(AND(d<>{"h","v"}),"check arg",
      LET(u,UPPER(d),a,"APP"&n&u&"=LAMBDA(a1r,a2r,",b,"[a"&SEQUENCE(,n-2,3)&"r],",
        c,CONCAT("APP2"&u&"(a"&SEQUENCE(,n-1)&"r,")&"a"&n&"r",e,REPT(")",n-1),
          CONCAT(a,b,"LET(x,",c,e,",FILTER(x,"&IF(d="v","BYROW","BYCOL")&"(--(x<>""""),LAMBDA(a,SUM(a))))))"))
     )
)
LAMBDA 1.1.1.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAF
1Task: If your routine requires appending n arrays, let's say 5 arrays, horizontally
2step 1: call APPNHV(5,"h")
3step 2: copy the cell and paste it as value to any other cell
4step 3: define the new APP5H
5Note: for simplicity did not include row/column index or offset arguments found on APP2H and APP2V
6=APPNHV(5,"h")
71.) APP5H=LAMBDA(a1r,a2r,[a3r],[a4r],[a5r],LET(x,APP2H(a1r,APP2H(a2r,APP2H(a3r,APP2H(a4r,a5r)))),FILTER(x,BYCOL(--(x<>""),LAMBDA(a,SUM(a))))))
82.) copy B7 and paste as value
9APP5H=LAMBDA(a1r,a2r,[a3r],[a4r],[a5r],LET(x,APP2H(a1r,APP2H(a2r,APP2H(a3r,APP2H(a4r,a5r)))),FILTER(x,BYCOL(--(x<>""),LAMBDA(a,SUM(a))))))
103.) define APP5V in the name manager
11Important note:
12Due to how new function is created , the arguments after second array are optional ,
13we can use the same created function for appending any nr. of arrays 2<nr<=n ,
14simply by omitting arguments
15Arrays can be anywere on the woorkbook
16
17a111a2222a33a44444a555
1811223444
192224444
204444
21
22ignore 3rd argument
23=APP5H(B17:C18,F17:H19,K17:K18,N17:Q20,T17:U17)=APP5H(B17:C18,F17:H19,,N17:Q20,T17:U17)
2411222344445511222444455
25112234441122444
2622244442224444
2744444444
28
29arg. omitted,only 3 arrays, dif.order
30=APP5H(B17:C18,N17:Q20,F17:H19)
31114444222
321144422
334444222
344444
35
APPNH H post
Cell Formulas
RangeFormula
B6,B30,O23,B23B6=FORMULATEXT(B7)
B7B7=APPNHV(5,"h")
B24:M27B24=APP5H(B17:C18,F17:H19,K17:K18,N17:Q20,T17:U17)
O24:Y27O24=APP5H(B17:C18,F17:H19,,N17:Q20,T17:U17)
B31:J34B31=APP5H(B17:C18,N17:Q20,F17:H19)
Dynamic array formulas.
 

Forum statistics

Threads
1,224,813
Messages
6,181,117
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