Share via

Dynamic array function to split value into rows

Anonymous
2024-09-28T11:03:39+00:00

I want to try an array formula that spills

I tried this =HSTACK(J18,TOCOL(TEXTSPLIT(K18," "))) but number in A column doesn't repeat

Sample data

898990 Cat Mat
898767 Nam Bam
767676 Gam Jam

Either way is okay

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Ashish Mathur 101.8K Reputation points Volunteer Moderator
2024-09-28T23:15:16+00:00

Hi,

I would solve this in the Query Editor. However, if you wish to use a formula, then enter this formula in cell D2

=LET(spt,DROP(REDUCE(" ",B2:B4,LAMBDA(a,b,VSTACK(a,TEXTSPLIT(b," ")))),1),HSTACK(TOCOL(IF(spt<>"",A2:A4),2),TOCOL(spt,2)))

Hope this helps.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

Answer accepted by question author

Anonymous
2024-09-28T13:29:46+00:00

This one?

=HSTACK(TEXTSPLIT(TEXTJOIN(" ",,TRIM(REPT(A1:A3&" ",2))),," "),TEXTSPLIT(TEXTJOIN(" ",,B1:B3),," "))

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

6 additional answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. Anonymous
    2024-09-28T14:39:50+00:00

    Exactly, I was tying figure out this part TEXTJOIN(" ",,TRIM(REPT(J18:J19&" ",2))) how to add space in REPT I was exploring MID for that.

    I was trying to make use MAP LAMDA EXPAND FILTER to repeat column A values

    You hard coded 2 in REPT need to make it dynamic for below example it will return #N/A

    77676 GTR NNT MMU

    Updated formula that works on more than 2 values in column B

    =HSTACK(TEXTSPLIT(TEXTJOIN(" ",,TRIM(REPT(J18:J20&" ",MAP(K18:K20,LAMBDA(x,COUNTA(TEXTSPLIT(x," "))))))),," "),TEXTSPLIT(TEXTJOIN(" ",,K18:K20),," "))

    Image

    Update the range in LET

    =LET(num,J18:J20,txt,K18:K20,HSTACK(TEXTSPLIT(TEXTJOIN(" ",,TRIM(REPT(num&" ",MAP(txt,LAMBDA(x,COUNTA(TEXTSPLIT(x," "))))))),," "),TEXTSPLIT(TEXTJOIN(" ",,txt),," ")))

    Image

    Was this answer helpful?

    0 comments No comments