2

Is there a quick way to increase/decrease a cell value by 1 in Apple iWork's Numbers?

1 Answer 1

2

Numbers provides an interface for AppleScript. Open Automator.app and create a new Service. Here, drag Run AppleScript from the left to the right pane.

Now, paste the following AppleScript with a bit of copypasta from here:

tell application "Numbers"
    set tTables to (tables of sheets of front document whose its selection range is not missing value)
    repeat with t in tTables -- tables of each sheet
        if contents of t is not {} then -- the list is not empty, it's the selected sheet
            set tCells to cells of selection range of (get item 1 of t) -- selection in active table
            repeat with i in tCells -- each selected cell
                set val to value of i
                set value of i to (val + 1)
            end repeat
            return
        end if
    end repeat
end tell

Save this workflow as Increase Cell Value or similar. Close the service and create another one. Now, do the same again, but change val + 1 to val - 1, and save it as Decrease Cell Value.

Finally, go to System Preferences » Keyboard » Keyboard Shortcuts. Here, under Services, assign a keyboard shortcut to your new actions, for example I to increase and I to decrease.

Once this is done, you can just select any number of (numeric) cells in Numbers and hit your (global) keyboard shortcut.

Before and after:

Your services are also available through the Numbers menu:

Of course, one could do some further error checking for cells that contain text, but you get the idea.

4
  • Brill, I'll try it out now, I don't suppose you know how to get the value of one cell depending on if another cell of the same row matches a particular value?
    – rctneil
    Oct 20, 2012 at 9:49
  • The AppleScript suite allows you to traverse rows and columns, e.g. combining repeat with c in … and accessing cells like cell 1 of row 2 of table 1 of sheet 1, but I'd rather do this with built-in functions in Numbers itself if possible. But I'm not a spreadsheet expert so I'm not sure which functions you'd need, sorry.
    – slhck
    Oct 20, 2012 at 9:53
  • I've created the services but the shortcuts do not work and they are not listed under the services menu. I have restarted Numbers too.
    – rctneil
    Oct 20, 2012 at 9:58
  • It works for me. Have you made sure the keyboard shortcut isn't used by anything else? For example, I use ⌥⌘I to increase and ⌥⇧⌘I to decrease and it works right away.
    – slhck
    Oct 20, 2012 at 10:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .