Forum Discussion
castre1984
Mar 19, 2021Copper Contributor
How to repeat same number every n rows in the same column
Hi, I need to repeat the same number every n rows within the same column, any thoughts? Also, how can I do the same using a formula rather than a number? Also, and I think , slightly mor...
mtarler
Mar 19, 2021Silver Contributor
Maybe sharing the sheet and/or more details on what you have and are trying to do would help.
To repeat a number every n rows just do the 1st set of n rows, copy, then select the whole range of rows you want to fill that way and paste.
The same method works whether the value in the cells are numbers, text or formulas
but the formula needs to be written accurately to indicate if any particular cell reference is ABSOLUTE or RELATIVE. By that I mean if a formula in cell A1 is =B1 + 1 then you copy that down to A2 then A2 will have a formula =B2 + 1 because it will adjust B1 down to B2 accordingly. If instead you wanted it to stay with B1 then add $ before each 'fixed' component. So if A1 had =$B$1 + 1 then that reference to $B$1 will not change regardless of it being copied to a new cell location. Notice there is a $ before both the B and the 1 but you can also choose to only 'fix' one or the other: $B1 or B$1 so $B1 will fix the B but not the 1 so if you copy down rows the 1 will change but if you copy to the a different column the B will not. and similarly with B$1 if you copy to C1 then the B will change to D but if you copy down rows the 1 will stay fixed.
Finally as for detecting the color of the cell, that is only possible using VBA (macros). IF that color is being applied based on a conditional formatting rule then you can create a formula that replicates that rule to do the appropriate action.
To repeat a number every n rows just do the 1st set of n rows, copy, then select the whole range of rows you want to fill that way and paste.
The same method works whether the value in the cells are numbers, text or formulas
but the formula needs to be written accurately to indicate if any particular cell reference is ABSOLUTE or RELATIVE. By that I mean if a formula in cell A1 is =B1 + 1 then you copy that down to A2 then A2 will have a formula =B2 + 1 because it will adjust B1 down to B2 accordingly. If instead you wanted it to stay with B1 then add $ before each 'fixed' component. So if A1 had =$B$1 + 1 then that reference to $B$1 will not change regardless of it being copied to a new cell location. Notice there is a $ before both the B and the 1 but you can also choose to only 'fix' one or the other: $B1 or B$1 so $B1 will fix the B but not the 1 so if you copy down rows the 1 will change but if you copy to the a different column the B will not. and similarly with B$1 if you copy to C1 then the B will change to D but if you copy down rows the 1 will stay fixed.
Finally as for detecting the color of the cell, that is only possible using VBA (macros). IF that color is being applied based on a conditional formatting rule then you can create a formula that replicates that rule to do the appropriate action.
- castre1984Mar 20, 2021Copper Contributor
Thanks in advance for you answer, I am adding an excel doc to be more precise, you can find my questions in the question sheet.