I have a list of (unique) numbers which I want to drag on another column but have it repeat each an X number of times.
Column A: current data;
Column B: desired output for X=2;
--------------------------------------------------
| | A | B |
--------------------------------------------------
| 1 | Number | Repeat number twice |
--------------------------------------------------
| 2 | 123 | 123 |
--------------------------------------------------
| 3 | 231 | 123 |
--------------------------------------------------
| 4 | 444 | 231 |
--------------------------------------------------
| 5 | 312 | 231 |
--------------------------------------------------
| 6 | 543 | 444 |
--------------------------------------------------
I want a way of dragging down starting at B2 all the way down to B:1000 and repeat each number in column A an X amount of times.
Best Answer
It's possible with a rather simple formula. Enter this formula in the first cell you want to drag from, and then just drag down.
=INDIRECT("A"&(ROUNDUP(ROW(A1)/2)+ROW(A$2)-1))
Explanation
INDIRECT()
takes a string argument and returns a cell reference"A"&
just tells us which column to look for values inROUNDUP(ROW(A1)/2)
is what gives is the repeating row numbers+ROW(A$2)-1
moves down to the specific row.+ROW(A$1)
), but it wouldn't work when the value is in the first rowModification
You'd have to modify this if the cells aren't exactly as in your example.
If, for example, your first value is in B12 you change it to:
=INDIRECT("B"&(ROUNDUP(ROW(B1)/2)+ROW(B$12)-1))