M
M
maratmd2021-07-28 07:48:56
Google Sheets
maratmd, 2021-07-28 07:48:56

How to make a link to a cell in the form of a script?

Hello, I have a very long table, and with the help of buttons I want to make my own menu, which I will attach on the first line. As I understand it, you can attach a script to each button. How can, for example, make a script that will lead, for example, to cell A956, and so on. One button leads to one cell, the second button to another. I tried to make just links to cells, it doesn’t look very good, because when you hover, a link appears that you need to click on. And I would like just a button, like on the sites.

If anyone knows, I will be glad for a detailed answer, since I do not really understand this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2021-07-28
@maratmd

Add the following code to your Table project

const goToWrapper_ = (address) => {
  const range = getRangeByRefString_(SpreadsheetApp.getActiveSheet(), address);
  range.getSheet().getRange('A1').activate();
  range.activate();
}

function getRangeByRefString_(sheet, refString) {
  return refString.indexOf('!') === -1 ?
    sheet.getRange(refString) :
    sheet.getParent().getRange(refString);
}

function goTo555() {
  goToWrapper_('A555');
}

function goToSheet5A555() {
  goToWrapper_('Sheet5!A555');
}

Assign the script to the button
6100fb73c48a3821432145.png
Example in Spreadsheet https://docs.google.com/spreadsheets/d/1XO63gawVjR...
You can create a quick menu (not a button) for almost any address. But there you have to call the menu. And that's a whole click more!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question