Repeating rows

sharshra

Active Member
Joined
Mar 20, 2013
Messages
404
Office Version
  1. 365
I have to repeat few rows in a table. I´m using REPT function in the formula, but it is throwing an error. Can the experts please advise?

Source table has multiple dept for each name & role. I have to split dept & create one line item for each dept. Result should be as shown in the desired output table below. But the REPT seems to be throwing error as seen in the actual output. Seems to be something wrong in this line. Can this be fixed? Or any suggestions for a better solution to get the desired output?
Excel Formula:
b, DROP(REDUCE("",Table9,LAMBDA(x,y,VSTACK(x,REPT(CHOOSECOLS(y,1,2),COLUMNS(TEXTSPLIT(CHOOSECOLS(y,3),",")))))),1),

Source table:
excel problems.xlsx
ABC
1nameroledept
2dsfdfa12221, 67, 434
3fdhgh56, i89709, 4, 74, 491
4mcznja75, 221, 74, 4, 709, t55
5qeknb8w67
Sheet7


Actual output:
excel problems.xlsx
K
2#VALUE!
Sheet7
Cell Formulas
RangeFormula
K2K2=LET( n,Table9[name],r,Table9[role],d,Table9[dept], a,DROP(REDUCE("",d,LAMBDA(x,y,VSTACK(x,TOCOL(TRIM(TEXTSPLIT(y,",")),3)))),1), b, DROP(REDUCE("",Table9,LAMBDA(x,y,VSTACK(x,REPT(CHOOSECOLS(y,1,2),COLUMNS(TEXTSPLIT(CHOOSECOLS(y,3),",")))))),1), HSTACK(b,a))


Desired output:
excel problems.xlsx
EFG
1nameroledept
2dsfdfa12221
3dsfdfa1267
4dsfdfa12434
5fdhgh56, i89709
6fdhgh56, i894
7fdhgh56, i8974
8fdhgh56, i89491
9mcznja75
10mcznj221
11mcznj74
12mcznj4
13mcznj709
14mcznjt55
15qeknb8w67
Sheet7
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try the following:

Excel Formula:
=LET(
    d, ",",
    n, LEN(Table9[dept])-LEN(SUBSTITUTE(Table9[dept], d, ))+1,
    c, SEQUENCE(, MAX(n)),
    f, LAMBDA(a, TOCOL(IFS(n>=c, a), 2)),
    v, TOCOL(TRIM(TEXTBEFORE(TEXTAFTER(d&Table9[dept]&d, d, c), d)), 2),
    VSTACK(Table9[#Headers], HSTACK(f(Table9[name]), f(Table9[role]), IFERROR(VALUE(v), v)))
)
 
Upvote 1
Solution

Forum statistics

Threads
1,224,812
Messages
6,181,089
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