The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniOutliner > OmniOutliner 3 for Mac
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Can you create sequential dates? Thread Tools Search this Thread Display Modes
I'm guessing there's no copying function for columns like in Excel, but is there a way to create a column and have it fill in sequential dates?
 
You could assign a script to a keystroke or toolbar button.

If, for example, you select a date or number column by clicking on its header (so that the whole column has a blue highlight) the following script will fill the cells of all rows with values derived from those of the first one or two rows.

(The difference between row values defaults to one day (or 1.0) but if row 2 already contains a value when the script is run, the series will continue the interval/difference between rows 1 and 2).

Code:
-- FILL DATE OR NUMBER COLUMN WITH VALUES
-- BASED ON THE VALUES IN THE FIRST ONE OR TWO ROWS

tell application id "OOut"
	if (count of documents) < 1 then return
	tell front document
		set lngRows to count of rows
		if lngRows < 3 then return
		set lstSeldCols to selected columns
		if (count of lstSeldCols) < 1 then return
		set {eType, idCol} to {type, id} of first item of lstSeldCols
		
		if eType is not in {number, date} then return
		set {varStart, varNext} to {value of cell id idCol of row 1, value of cell id idCol of row 2}
		
		if eType = number then
			if varNext is missing value then
				set varDelta to 1
				set iStart to 2
			else
				set iStart to 3
				set varDelta to varNext - varStart
			end if
			
			-- FILL REMAINING CELLS WITH NUMBERES
			repeat with i from iStart to count of rows
				set value of cell id idCol of row i to varStart + (varDelta * (i - 1))
			end repeat
		else -- date
			if varNext is missing value then
				set varDelta to 1
				set iStart to 2
			else
				set varDelta to ((varNext - varStart) / days) as integer
				set iStart to 3
			end if
			
			-- FILL REMAINING CELLS WITH DATES
			repeat with i from iStart to lngRows
				set value of cell id idCol of row i to varStart + (varDelta * (i - 1) * days)
			end repeat
		end if
	end tell
end tell
 
Or, if you need to select only a subset of rows to fill (rather than selecting and filling a whole column) something like the following:

Code:
property pTitle : "Fill rows with dates/numbers"
property pVer : "0.2"

-- FILL DATE OR NUMBER COLUMN WITH VALUES
-- BASED ON THE VALUES IN THE FIRST ONE OR TWO 
-- SELECTED ROWS

tell application id "OOut"
	if (count of documents) < 1 then return
	tell front document
		set lstRows to selected rows
		set lngRows to count of lstRows
		if lngRows < 3 then
			display dialog ¬
				"Select two or more rows," & return & return & ¬
				"(With at least a start value in the relevant column of the first selected row)." buttons "OK" default button "OK" with title pTitle & "    " & pVer
			return
		end if
		
		-- CHOOSE A DATE OR NUMBER COLUMN
		set refCols to a reference to (columns where type is date or type is number)
		if (count of refCols) < 1 then
			display dialog ¬
				"Requires at least one column of type date or number." buttons "OK" default button "OK" with title pTitle & "    " & pVer
			return
		end if
		set varChoice to choose from list (name of refCols) as list with prompt ¬
			"Column to fill:" with title pTitle & "   " & pVer
		if varChoice is false then return
		set oCol to column named (first item of varChoice)
		set {eType, idCol} to {type, id} of oCol
		
		-- GET VALUES FROM THE FIRST (AND PERHAPS SECOND) ROWS
		set {varStart, varNext} to {value of cell id idCol of item 1 of lstRows, ¬
			value of cell id idCol of item 2 of lstRows}
		
		set varDelta to 1
		set iStart to 2
		
		if eType = number then
			if varNext ≠ missing value then
				set iStart to 3
				set varDelta to varNext - varStart
			end if
			
			-- FILL REMAINING CELLS WITH NUMBERS
			repeat with i from iStart to lngRows
				set value of cell id idCol of item i of lstRows to varStart + (varDelta * (i - 1))
			end repeat
		else -- date
			if varNext ≠ missing value then
				set varDelta to ((varNext - varStart) / days) as integer
				set iStart to 3
			end if
			
			-- FILL REMAINING CELLS WITH DATES
			repeat with i from iStart to lngRows
				set value of cell id idCol of item i of lstRows to varStart + (varDelta * (i - 1) * days)
			end repeat
		end if
	end tell
end tell

Last edited by RobTrew; 2011-12-20 at 12:20 PM..
 
Wow, thanks. I think I used a script once in my life, if you could help me with instructions on how to use that code, I'd appreciate it.

Last edited by FredH; 2011-12-20 at 02:48 PM..
 
Quote:
Originally Posted by FredH View Post
instructions on how to use that code
I would start with the second of those two scripts, copying all of the script (making sure no lines get missed) and pasting it into the Applescript Editor application.

Thereafter, the instructions are the same as for running OmniFocus scripts, as summarized here.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assign Project Due Dates Without Action Due Dates Revearti OmniFocus 1 for Mac 8 2014-05-12 05:58 AM
Sequential Projects and Due Dates glen.saberton OmniFocus 1 for Mac 4 2012-12-09 12:43 PM
Start dates on sequential projects Jay6821 OmniFocus 1 for Mac 4 2012-09-18 07:17 PM
How to create a swimlane diagram that is not linked to specific dates? skippingrock OmniPlan General 0 2011-04-01 12:29 PM
Sequential project start dates JBB OmniFocus 1 for Mac 2 2011-02-09 09:45 PM


All times are GMT -8. The time now is 11:39 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.