How to create arrayformula sequence number separated by comma in google spreadsheets expected results is in column B
| A | B |
|---|---|
| 5 | 1,2,3,4,5 |
| 2 | 1,2 |
| 3 | 1,2,3 |
How to create arrayformula sequence number separated by comma in google spreadsheets expected results is in column B
| A | B |
|---|---|
| 5 | 1,2,3,4,5 |
| 2 | 1,2 |
| 3 | 1,2,3 |
How about the following sample formula?
=JOIN(",",ARRAYFORMULA(ROW(INDIRECT("A1:A"&A1))))
"A1:A"&A1 using INDIRECT.ROW., using JOIN.When you want to put all result values using one formula, unfortunately, I couldn't find the formula using the built-in functions. In that case, I would like to propose to a custom function as follows. When you use this, please copy and paste the following script to the script editor of Spreadsheet.
And, please put a formula of =SAMPLE(A1:A) to a cell "B1". By this, the result values are put to the column "B" using the values of column "A".
const SAMPLE = v => v.map(([e]) => e && !isNaN(e) ? [...Array(e)].map((_, i) => i + 1).join(",") : "");
You can use TEXTJOIN() with SEQUENCE() function.
=TEXTJOIN(",",TRUE,SEQUENCE(A1))
You can also use this functions in desktop Excel365