1

I have two dynamic arrays in the same spreadsheet, called Input and Length:

Input =TRANSPOSE(BASE(DEC2BIN(CODE(MID(A1,(SEQUENCE(1,LEN(A1),,1)),1))),10,8))

Length =TRANSPOSE(MID(BASE((LEN(A1)*8),2,64),SEQUENCE(1,8,,8),8))

Input       Length
01010011    00000000
01101111    00000000
01101101    00000000
01100101    00000000
00100000    00000000
01100111    00000000
01110101    00000000
01101001    10110000
01100100    
01100001    
01101110    
01100011    
01100101    
00100000    
01101110    
01100101    
01100101    
01100100    
01100101    
01100100    
00100000    
00100000

I want to combine them into a single array:

01010011
01101111
01101101
01100101
00100000
01100111
01110101
01101001
01100100    
01100001    
01101110    
01100011    
01100101    
00100000    
01101110    
01100101    
01100101    
01100100    
01100101    
01100100    
00100000    
00100000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
10110000

The formula I am attempting to use is:

=INDEX((Input,Length),SEQUENCE(ROWS(Input)+ROWS(Length)))

However the Length range is generating a #REF! error, which I cannot resolve:

01010011
01101111
01101101
01100101
00100000
01100111
01110101
01101001
01100100    
01100001    
01101110    
01100011    
01100101    
00100000    
01101110    
01100101    
01100101    
01100100    
01100101    
01100100    
00100000    
00100000
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!
#REF!

I have attempted to use other functions which either failed to combine the arrays, and/or generated various other #NUM! and #VALUE! errors.

I have also swapped the order from Input,Length to Length,Input, which generates the same #REF! error for the second array.

I suspect I have been looking at it too long and simply need fresh eyes.

I want to use native Excel functions and formulas instead of VBA or other programmatic approaches.

2
  • look here: stackoverflow.com/q/71022776/16578424. And be aware that you will reference the "input" range by referencing the cell where the formula is entered plus # --> A1# - you do not reference the whole range because this might change. Commented Mar 3, 2022 at 11:02
  • @Ike I understand the spill issue, which is why I used the SEQUENCE function to create a dynamic definition of the rows. I tried what I think you're suggesting: =INDEX((B2#,C2#),SEQUENCE(ROWS(B2#)+ROWS(C2#))), which still results in the #REF! error. Commented Mar 3, 2022 at 11:39

1 Answer 1

2

One way:

=TEXT(FILTERXML("<a><b>"&TEXTJOIN("</b><b>",1,TRANSPOSE(IFNA(IF(SEQUENCE(,2,0),Length,Input),"")))&"</b></a>","//b"),REPT(0,8))

More rigorous alternative:

=LET(α,ROWS(Input),β,ROWS(Length),γ,MAX(α,β),δ,SEQUENCE(2*γ,,0),ε,INDEX(CHOOSE(SEQUENCE(,2),Input,Length),1+MOD(δ,γ),1+QUOTIENT(δ,γ)),FILTER(ε,1-ISNA(ε)))

Sign up to request clarification or add additional context in comments.

5 Comments

This works to a limit. When the Input array is generated from the maximum Excel cell capacity of 32,767 characters, this formula results in a #CALC! error.
Have added a more rigorous alternative.
Holy sheet! More rigorous indeed @Jos! At this point I will confirm it works, although I have little idea on how. Clearly over my skis here. I need to do some additional downstream work on this, before I close it out. Thank you!
Great stuff @Jos! I was even able to expand your formula further: =LET(α,ROWS(B2#),β,ROWS(C2#),ç,ROWS(D2#),γ,MAX(α,β,ç),δ,SEQUENCE(3*γ,,0),ε,INDEX(CHOOSE(SEQUENCE(,3),B2#,C2#,D2#),1+MOD(δ,γ),1+QUOTIENT(δ,γ)),FILTER(ε,1-ISNA(ε)))
@konalion Nice work!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.