Jump to specific cell in google spreadsheets macro

Viewed 517

I am aware of f5 to open the jump to cell dialog, the problem with it, is that, while it allows you to do it once, the next time you press f5, to jump to another specific cell, the previous text is not highlighted, therefore you need to get you hands off the keyboard and select it with the mouse.

If I could have a way where I don't lift my hands from the keyboard it would speed up my workflow tremendously.

Any ideas?

Like, I'd need a macro to pop up the goto range dialog AND select whatever text is there so that I can just type a new cell range (e.g: a391)

Thank you!

4 Answers

There is a simple approach to add customized macros to Sheets. You only need to create a bounded script beforehand that contains a function with your desired actions. Then you can follow these steps:

  1. Go to Tools > Macros > Import
  2. Find your function and click on Add Function and click on the X to close.
  3. Go to Tools > Macros > Manage Macros
  4. Assign a number to your macro and click on Update
  5. Run your macro using Ctrl + Alt + Shift + {NUMBER}

Following those steps you will create a customized macro without difficulty, but feel free to ask me any doubts.

Keyboard shortcuts in Google Spreadsheets are rather suck. If you're on Windows I'd advice to try Autohotkey. It can move cursor at any coordinates on your screen (coordinates can be set relative current window). For example 'Win+F5' could work as F5 + move cursor at top-right corner of the screen and perform a left click.

Work around for MacOS (High Sierra, probably it will work on newer os as well)

I downloaded the file AppleScript Toolbox.osax from here: https://astoolbox.wordpress.com/

Put the file in the folder: /Users/me/Library/ScriptingAdditions

Run Automator and start a new Service:

enter image description here

enter image description here

Paste this script

activate application "Firefox" -- or "Safari" or "Chrome", etc
set mousePointLocation1 to {1700, 250} -- coordinates depend on your screen size
AST click at mousePointLocation1 number of clicks 1

And save:

enter image description here

Go to Preferences > Keyboard > Services and add shortcut for this service

enter image description here

After that you will see the new shortcut here:

enter image description here

In Google Spreadsheet I press F5, to show the panel and then I press ^F5 and cursor jump on this panel and does click.

I'm a noob in macOS I'm sure it can be done better. It's just how I managed to do it right now.

Another modification of the script could be more convenient:

activate application "Firefox"

tell application "System Events" 
  key code 96 -- this is F5 key
end tell

delay .5

AST click at {1700, 250} number of clicks 2 -- or 3 maybe

This way you don't need to press F5. Just press ^F5 and go ahead.


It works

enter image description here


Just in case. If you know Python. I've managed to press F5 move and click mouse with Python module pynput:

from pynput import mouse, keyboard

k = keyboard.Controller()
k.press(keyboard.Key.f5)
k.release(keyboard.Key.f5)

m = mouse.Controller()
m.position = (1700, 240)
m.press(mouse.Button.left)
m.release(mouse.Button.left)
m.click(mouse.Button.left, 2)

https://pynput.readthedocs.io/en/latest/

It can be converted into macOS Service this way:

enter image description here

And then you can run this Service the same way via Keyboard > Services > Add Shortcut

I just found another a much more obvious native solution.

Put the code in Script Editor:

function jump() {
  var range = SpreadsheetApp.getUi().prompt('Input cell').getResponseText();
  SpreadsheetApp.getActiveSheet().getRange(range).activate();
}

Save it and add the function as a macros:

enter image description here

enter image description here

Then assign some shortcut to the macros:

enter image description here

enter image description here

After that you can press the shortcut (CmdOptionShift5 in my case), input cell address, press Tab and Enter and here we go.

enter image description here

Related