Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Numbers, column width copy

Say I was grabbing 5 columns, and set their width to a new one, differing from the default, distributed evenly to each. Is it possible to copy ONLY the column width and paste this property to a selection of new set of 5 columns? What I am asking is more or less MS Excel Copy + "Paste Special" -> "Column width".

MacBook Pro, OS X Yosemite (10.10.3)

Posted on Jul 26, 2015 7:55 AM

Reply
2 replies

Jul 26, 2015 2:41 PM in response to afisher0106

Hello


As far as I know there's no such built-in feature of Numbers. Alternatively you may try the following AppleScript scripts to copy and paste cells' dimensions.


To use them, first select source range in Numbers and run the COPY DIMENSIONS SCRIPT which will put dimensions data in clipboard. Then select the target range and run the PASTE DIMENSIONS SCRIPT which will ask to select Width or Height (or Both) to paste and paste the selected properties. Currently if the target range is larger than source range, the source pattern is repeated to cover the target range. You may disable this behaviour by setting property |REPEAT| in PASTE DISENSIONS SCRIPT to false.


You may run the scripts via Script menu or as Automator services with optional keyboard shortcuts defined.


Tested with Numbers v2 under OS X 10.6.8.


Good luck,

H


--COPY DIMENSIONS SCRIPT _main() on _main() tell application "Numbers" activate tell (document 1's sheet 1 whose tables's selection range's class contains range) tell (table 1 whose selection range's class = range) if not (exists) then return tell selection range set ww to columns's width set hh to rows's height end tell end tell end tell end tell set the clipboard to {class:«class DIMS», list:{ww, hh}} --the clipboard end _main --END OF COPY DIMENSIONS SCRIPT



--PASTE DIMENSIONS SCRIPT _main() on _main() script o property |DIMENSIONS| : {"Width", "Height"} property |REPEAT| : true try set dd to the clipboard as «class DIMS» on error number -1700 return display dialog "Dimensions data is not in clipboard." end try set {ww, hh} to dd's list tell application "Numbers" activate tell (document 1's sheet 1 whose tables's selection range's class contains range) tell (table 1 whose selection range's class = range) if not (exists) then return set r to choose from list |DIMENSIONS| with prompt "Choose dimension(s) to paste" with multiple selections allowed if r = false then error number -128 tell selection range if r contains |DIMENSIONS|'s item 1 then -- width set ix to count ww repeat with i from 1 to count columns if not |REPEAT| and i > ix then exit repeat set column i's width to ww's item ((i - 1) mod ix + 1) end repeat end if if r contains |DIMENSIONS|'s item 2 then -- height set ix to count hh repeat with i from 1 to count rows if not |REPEAT| and i > ix then exit repeat set row i's height to hh's item ((i - 1) mod ix + 1) end repeat end if end tell end tell end tell end tell end script tell o to run end _main --END OF PASTE DIMENSIONS SCRIPT

Jul 26, 2015 4:02 PM in response to afisher0106

In Numbers 3 there is no Paste Special > Column Width.


First note in Numbers 3 that to add columns of the same width as the previous all you need to do is click as shown by the arrow here:

User uploaded file


Five quick clicks and you're done.


If you do need to use the AppleScript approach (say you are pasting the width to columns that are not adjacent) then in Numbers 3 the script can be quite simple.


To copy the width to the clipboard:


--copies column width to clipboard

tell application "Numbers"

tell document 1 to tell active sheet

set t to first table whose selection range's class is range


set the clipboard tot'sselection range'scolumn 1's width as text

end tell

end tell


To paste the width to selected new columns:


--sets width of selected columns to value in the clipboard

tell application "Numbers"

tell document 1 to tell active sheet

set t to first table whose selection range's class is range

set selRng to t'sselection range

repeat with c in selRng's columns

set c'swidth to the clipboard

end repeat

end tell

end tell



SG

Numbers, column width copy

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