Add 7 Days From Date Above (Shortcuts Numbers Action)

How do I add 7 days from the date above using a formula that will be added to the sheet using a shortcuts action?


I have 4/24 in A2 and I am using the shortcut action “Add Row to Top or Bottom of Table”


I tried =Sum(A+7) and I get an error. Leaving the number out and only referencing the letter worked for currency but it isn’t working for dates.


I tried = Sum(A2+7) the only problem is when the shortcut is ran again you get 4/24 again instead of 5/1.


I need a formula that adds 7 days from the date in the cell above.


I’m using Numbers App on IPhone.

iPhone 12

Posted on Apr 26, 2024 8:27 PM

Reply
1 reply

Apr 27, 2024 7:55 AM in response to CAndrew91

A couple of things:

  • The SUM function is not required
  • SUM(A+7) will sum all the values in column A and add 7 to it. If the formula is in column A, is a circular reference (the formula one of the cells being summed). Also, you cannot sum dates (for example, 4/1/24 + 4/2/24 makes no sense).
  • Telling it to put the formula A2+7 into a cell means exactly that. It will not be A3+7 then A4+7, etc., only A2+7.


If you want the formula in the cell, you don't need a shortcut or script, you can enter the formula one time in the table and the new rows will get it. If A2 is a date, put the formula =A2+7 into cell A3. When you add a new row, the formula will populate to the new row automatically. All rows other than row 2 will be formulas.


If you want the cells to have the actual value of the row above +7, that takes a little more effort. To do what you want to do requires AppleScript. Run AppleScript is one of the actions available in Shortcuts. Use that action. Delete the default text and replace it with the text below (or a better script is someone has a better way to do it):


tell application "Numbers"
	tell front document
		tell active sheet
			tell (first table whose selection range's class is range)
				add row below last row
				set value of cell 1 of last row to "=A" & ((address of last row) - 1) & "+7"
				set value of cell 1 of last row to (value of cell 1 of last row)
			end tell
		end tell
	end tell
end tell


The way I did it is kind of a strange way to add 7 to a cell but there is a reason I did it this way. First, I wanted it to work on any value that can have a 7 added to it in Numbers. Numbers does things differently than AppleScript. If I simply added 7 in the script, the result would be the previous date + 7 seconds, not 7 days. So I created the Numbers formula to add 7 to the previous value then I replace the formula with the value that was calculated. Note that, in Numbers, it will show that the cell contains the formula until you click off the cell then click back onto it andthen it will be the actual value.

Add 7 Days From Date Above (Shortcuts Numbers Action)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.