autofill without dragging fill handle?
iMac, Mac OS X (10.5.6)
iMac, Mac OS X (10.5.6)
(*
Enregistrer le script en tant qu'Application ou Progiciel : autoNumber.app
déplacer l'application créée dans le dossier
<VolumeDeDĂ©marrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
Il vous faudra peut-ĂȘtre crĂ©er le dossier Numbers et peut-ĂȘtre mĂȘme le dossier Applications.
Sélectionnez la premiÚre cellule à numéroter.
menu Scripts > Numbers > autoNumber
Saisir le numéro de départ.
Le script remplit la cellule de départ et les cellules de rang supérieur dans la colonne ave la formule =LIGNE()-xx, xx étant calculé pour que la numérotation commence comme prévu.
+++++++
Save the script as an Application or an Application Bundle: autoNumber.app
Move the newly created application into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
Select the first cell to fill.
menu Scripts > Numbers > autoNumber
Type tha value of the starting number.
The script fills selected cell and those of higher index in its column with the formula =ROW()-xx where xx is calculated given the starting number.
Yvan KOENIG (Vallauris, FRANCE)
7 février 2009
*)
property theApp : "Numbers"
property delim : missing value
property ROW_loc : missing value
--=====
on run
if delim is missing value then
if character 2 of (0.5 as text) is "." then
set delim to ","
else
set delim to ";"
end if
set p2lproj to my getLproj(theApp)
set ROW_loc to my getLocalizedFuncName(p2lproj, "ROW")
end if
set {rName, tName, sName, dName} to my getSelection()
if rName is missing value then error "No selected cells"
set twoNames to my decoupe(rName, ":")
set {colNum1, rowNum1} to my decipher(item 1 of twoNames)
(* Here we know the starting point of the destination area. *)
tell application (path to frontmost application as string)
if my parleFrancais() then
set msg to text returned of (display dialog "Tapez le premier numéro à utiliser" default answer "1")
else
set msg to text returned of (display dialog "Enter the first number to use" default answer "1")
end if
end tell
try
set msg to msg as integer
on error
if my parleFrancais() then
error "Nombre entier attendu !"
else
error "Must be an integer number !"
end if
end try
set prem to rowNum1 - msg
tell application "Numbers" to tell document dName to tell sheet sName to tell table tName to tell column colNum1
set cMax to (get count row)
repeat with y from rowNum1 to cMax
set value of cell y to "=" & ROW_loc & "()-" & prem
end repeat
end tell
end run
--=====
on getSelection()
local mySelectedRanges, sheetRanges, thisRange, _, myRange, myTable, mySheet, myDoc, mySelection
tell application "Numbers" to tell document 1
set mySelectedRanges to selection range of every table of every sheet
repeat with sheetRanges in mySelectedRanges
repeat with thisRange in sheetRanges
if contents of thisRange is not missing value then
try
--return thisRange --poorly formed result
thisRange as text
on error errmsg number errNum
set {_, myRange, _, myTable, _, mySheet, _, myDoc} to my decoupe(errmsg, quote)
--set mySelection to (a reference to (range rn of table tn of sheet sn))
return {myRange, myTable, mySheet, myDoc}
end try
end if -- contentsâŠ
end repeat -- thisRange
end repeat -- sheetRanges
end tell -- document 1 of application
return {missing value, missing value, missing value, missing value}
end getSelection
--=====
on decipher(n)
local letters, colNum, rowNum
set letters to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
if (character 2 of n) as text > "9" then
set colNum to (offset of (character 1 of n) in letters) * 64 + (offset of (character 2 of n) in letters)
set rowNum to (text 3 thru -1 of n) as integer
else
set colNum to offset of (character 1 of n) in letters
set rowNum to (text 2 thru -1 of n) as integer
end if
return {colNum, rowNum}
end decipher
--=====
on decoupe(t, d)
local l
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to ""
return l
end decoupe
--=====
on getLocale(a, x)
tell application a to return localized string x
end getLocale
--=====
on getLocalizedFuncName(f, x)
return localized string x from table "Localizable" in bundle file f
end getLocalizedFuncName
--=====
on getLproj(aa)
local lprojName
set lprojName to my getlprojName(aa) & ".lproj"
return (path to application support as text) & "iWork '09:Frameworks:SFTabular.framework:Versions:A:Resources:" & lprojName
end getLproj
--=====
on getlprojName(aa)
local lprojs, localId, lproj
set lprojs to {{"da_DK", "da"}, {"nl_NL", "Dutch"}, {"en_US", "English"}, {"fi_FI", "fi"}, {"fr_FR", "French"}, {"de_DE", "German"}, {"it_IT", "Italian"}, {"ja_JP", "Japanese"}, {"ko_KR", "ko"}, {"no_NO", "no"}, {"pl_PL", "pl"}, {"pt_BR", "pt"}, {"pt_PT", "pt_PT"}, {"ru_RU", "ru"}, {"es_ES", "Spanish"}, {"sv_SE", "sv"}, {"zf_CN", "zh_CN"}, {"zh_TW", "zh_TW"}}
if aa starts with "Pages" then (* why are they using different strings ? *)
set localId to my getLocale(aa, "http://support.apple.com/manuals/#iwork")
else (* here for Keynote or Numbers *)
set localId to my getLocale(aa, "http://support.apple.com/en_US/manuals/#iwork")
end if
set localId to text (1 + (count of "http://support.apple.com/")) thru -1 of localId
set localId to text 1 thru ((offset of "/" in localId) - 1) of localId
set lproj to ""
repeat with i from 1 to count of lprojs
if localId is item 1 of item i of lprojs then
set lproj to item 2 of item i of lprojs
exit repeat
end if
end repeat
if lproj = "" then
if my parleFrancais() then
error "Le fichier FrameWorks " & localId & " manque !"
else
error "The Frameworks file " & localId & "is missing !"
end if
else
return lproj
end if
(* returns
da
Dutch
English
fi
French
German
Italian
Japanese
ko
no
pl
pt
pt_PT
ru
Spanish
sv
zh_CN
zh_TW
given the language used to display the program's GUI. *)
end getlprojName
--=====
on parleFrancais()
local z
try
tell application theApp to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z = "Annuler")
end parleFrancais
--=====
--[/SCRIPT]
Tom_Humphrey wrote:
Basically highlight all the cells you want to fill with the cell with the formula at the top then go insert>fill>up/down/left/right (depending on where the highlighted cells are
autofill without dragging fill handle?