Mar 19 2021 04:01 AM - last edited on Nov 09 2023 11:09 AM by
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 more complicated, How can I add a formula in a cell depending of the colour of another cell? Trying to explain myself I meant IF the colour of an specific cell is "X" then use this formula, if is "Y" use this another formula, is that possible? ,and also repeat this pattern every n rows in the same column?
I am not an expert in excel but I am trying to learn as much as possible to use for work as I am dealing with excel spreadsheets with a big amount of data and I think that would be useful rather than to add the numbers one per one, thanks in advance .
Julian
Mar 19 2021 10:15 AM
Mar 19 2021 11:19 PM - edited Mar 19 2021 11:49 PM
Your question has two part, and this one is addressing first one, Repeat number in certain Rows.
How it works:
=IF(MOD(ROW()-1,5),"",SUM(OFFSET(AC2,-4,0,4,1)))
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:
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.
Mar 20 2021 03:33 AM
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.
Mar 20 2021 03:36 AM
Mar 20 2021 03:49 AM
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.
Mar 20 2021 05:01 AM
@castre1984 hello, easiest is to use if function along with mod to make repeated pattern, then for colors use conditional formatting with formulas
attached sample, hope this helps
Mar 20 2021 05:42 AM
You shall insert the value in every 12th cell (5th in your case) without touching values in the cells in between. =$I$15 could work, but I'm not sure what are limitations.
Colors is another question, these are using of different formulas depends on cell color.