Forum Discussion
How to repeat same number every n rows in the same column
Your question has two part, and this one is addressing first one, Repeat number in certain Rows.
How it works:
- Create Index Column as shown in Col AC.
- Formula in cell AD2:
=IF(MOD(ROW()-1,5),"",SUM(OFFSET(AC2,-4,0,4,1)))
- Where 5 is Row interval, and -4 & 4 are value to repeat.
N.B. Remember Value to repeat must be smaller than Row interval.
Solution for Part two, if the cell has color then use a formula.
How it works:
- To get VB editor either press ALT+F11 or Right Click Sheet Tab, and from menu click View Code.
- Copy & Paste this VBA code as Module.
Function InteriorColor(CellColor As Range)
Application.Volatile
InteriorColor = CellColor.Interior.ColorIndex
End Function
3. Return to the Sheet, and Save the WB as Macro Enabled *.xlsm.
4. Write this formula in cell AJ2:
=IF(AI2>0,AH2+1,"No Color")
N.B. For neatness you may hide column AI.
Ragards
Julian
- SergeiBaklanMar 20, 2021Diamond Contributor
If without VBA
1) I'd create helper column (you may hide it) which fills down value in I15, other every 12 cell in column I could use reference on this helper column
2) To define an option I'd use not the cell property such as color, but some values, perhaps from drop-down list. Based on selected value you may do this or that calculations. To color the cell(s) you may use conditional formatting on the top.