I see lots of for (var i + code written but I have never been able to understand it. I can set a formula but I dont know how to manipulate it.
My current struggle is that I want my script setFormula(=A1+B2+X) to work by grabbing a value and minusing 1 from it. As I understand it would probably end up as setFormula(=A1+B2+" + i + ")"
In my specific case, X can either be 1 of the 2 following (ideally the 2nd one) to be 24 (by getting the value of 25 and then minusing 1 from it). The date on the sheet is the 25th of the month is in cell A1, and the tab (sheet) name is xxx25. I need to be able to have X as 25-1: we want to end up with it printing =A1+B2+24 into the cell.
1: Day(A1)-1 (if the day in A1 was 25th of a month, this would give us the result of 24)
So in cell A1 on the current sheet it has DD MMMM YYYY so lets say if its the 25th of a month and year, it will set the formula in the sheet as =A1+B2+24
2: The tab (sheet) name is xxx25. This tab will always have 3 letters followed by the day of the month.
(In my case I have 1 for each day of the month, such as xxx1 xxx2 .. xxx9 xxx10. If this needs to be changed on my side to xxx01 xxx02 .. etc I can do that if required.)
So I guess this method would grab the last 2 values of the sheetname (the date, which in the example is 25th) so it extracts(?) it from xxx25 and now remembers 25, minuses 1 from it, and places it into the formula to become =A1+B2+24
Thanks, please let me know if any explanation more is needed.
