• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Create Code Sequence

deciog

Active Member
Hi,

I would need a formula that would create column E according to the data that is in columns A, B and C.

Decio
 

Attachments

  • Modelo.xlsx
    11.3 KB · Views: 10
I can do the 365 bit, but converting it for 2016 is not going to be nice!
Code:
= LET(
    count,    1+end-start,
    close,    SCAN(0,count, LAMBDA(t,x,t+x)),
    open,     1 + close - count,
    k,        SEQUENCE(MAX(close)),
    row,      XMATCH(k,open,-1),
    instance, k+1-INDEX(open,row),
    baseCode, INDEX(Code,row),
    modifier, TEXT(INDEX(start,row)+instance-1,"0000"),
    VALUE(baseCode & modifier)
  )
Code:
 
A straightforward Power Query solution in cell G1 which should work in both those versions of Excel.
 

Attachments

  • Chandoo47817Modelo.xlsx
    21.4 KB · Views: 2
An old school formula for old Excel versions (Excel 2010 and up).

In F2, formula copied down :

=IFERROR(INDEX(A$2:A$11&TEXT(B$2:B$11,"0000"),AGGREGATE(15,6,ROW($1:$10)/((C$2:C$11-B$2:B$11+1)>=COLUMN(A:Y)),ROW(A1)))+RIGHT(AGGREGATE(15,6,ROW($1:$10)/1%+COLUMN(A:Y)/((C$2:C$11-B$2:B$11+1)>=COLUMN(A:Y)),ROW(A1)),2)-1,"")

78325
 

Attachments

  • StartAndEndCode.xlsx
    12.3 KB · Views: 3
Last edited:
Code:
="" & FILTERXML("<t><s>" & SUBSTITUTE(TEXTJOIN(", ",TRUE,BYROW(A2:C11,LAMBDA(a,ARRAYTOTEXT(INDEX(a,1)&TEXT(SEQUENCE(INDEX(a,3)-INDEX(a,2)+1,,INDEX(a,2)),"0000"),0)))), ", ", "</s><s>" ) & "</s></t>","//s")
 
p45cal Good morning.

My version doesn't have this ARRAYTOTEXT function Using the site https://en.excel-translator.de/translator/ , translating from English to Portuguese (Brazil) doesn't have this translation either

I updated it but it didn't help, this formula didn't work.

Could you post the model with this formula so that I can see if it will automatically translate


Thanks

Decio



Peter Bartholomew Good Morning.

I need you to post in the model because translating didn't work

I thank

Decio

bosco_yip Good morning.

It worked perfectly thank you

Decio
 
My version doesn't have this ARRAYTOTEXT function Using the site https://en.excel-translator.de/translator/ , translating from English to Portuguese (Brazil) doesn't have this translation either

I updated it but it didn't help, this formula didn't work.

Could you post the model with this formula so that I can see if it will automatically translate
You don't really need ARRAYTOTEXT - I was just exploring some of these newish functions.
In the attached, the Power Query solution, a formula with ARRAYTOTEXT, and a formula without ARRAYTOTEXT
 

Attachments

  • Chandoo47817Modelo.xlsx
    24 KB · Views: 3
p45cal


With the template attached, the formula was translated and I loved it because it has a lot of features.

In English ARRAYTOTEXT translated to Portuguese Brazil MATRIZPARATEXTO

Worked perfectly

Thanks
 
Here is another shorter formula option, being worked for Excel 2016 and up

In G2, formula copied down :

=IFERROR(1/(1/ROUND(IFNA(LOOKUP(1,0/(ROW(A1)=MMULT(N(COLUMN(A:J)<ROW($1:$11)),C$2:C$11-B$2:B$11)+ROW($1:$11)),A$2:A$12&TEXT(B$2:B$12,"0000")),G1+1),0)),"")

78332
 

Attachments

  • StartAndEndCode(BY).xlsx
    12.7 KB · Views: 2
For MS365 Please try

=LET(z,A2:C11,a,INDEX(z,,1),b,INDEX(z,,2),r,ROW(z),n,1+INDEX(z,,3)-b,m,MMULT(--(r>TRANSPOSE(r)),n),s,SEQUENCE(SUM(n),,0),LOOKUP(s,m,a*10^4+b)+s-LOOKUP(s,m))

or with new TOCOL function

=LET(z,A2:C11,a,INDEX(z,,1),b,INDEX(z,,2),n,1+INDEX(z,,3)-b,m,SEQUENCE(,MAX(n)),TOCOL(IF(n>=m,a*10^4+m+b-1,NA()),3))
 

Attachments

  • Modelo.xlsx
    13.4 KB · Views: 3
In the practical work, in order to avoid complicated formula, to adopt helper column and simpler formula is a nice option.

Here is a simpler formula with helper option, being worked for Excel 2016 and up

1] In D2 (helper), formula copied down :

=SUMPRODUCT(N(+C$1:C1)-N(+B$1:B1)+1)

2] In G2 (Result), formula copied down :

=IFERROR(1/(1/IFNA(INDEX(A$1:A$11&TEXT(B$1:B$11,"0000"),MATCH(ROW(A1),D:D,0)),G1+1)),"")

78356
 

Attachments

  • StartAndEndCode(BY2).xlsx
    13.8 KB · Views: 3
Back
Top