Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9788

how can I create a google sheets script to generate hyperlinks to corresponding tabs based on cell value?

$
0
0

I have a list and want to quickly add a hyperlink to the corresponding tab.Say my list is in column BC and looks like:

A

B

C

A

C

B

I would like all the A's to have a hyperlink to the sheet within the same google sheet to go to the sheet labeled "A".

It is quite a long list and would like to save time rather than hyperlinking each cell at a time by running a script of some sort.

I tried this:

function onEdit(e) {

var sheet = e.source.getActiveSheet();

var range = sheet.getActiveRange();

var val = range.getValues();

var col = range.getColumn();

var row = range.getRow();

var h_string = '=HYPERLINK("https://docs.google.com/spreadsheets/d/1QUICa667obThNZY3yXf-9MCc1Q3_-YEtvhVFn6tb6cI/edit#gid=1910200599'+val+'","'+val+'")';

if(col == 55) {

cell = sheet.getRange(col+row);cell.setFormula(h_string);

}

}

but line 2 doesn't work and I don't know why.

Thanks!


Viewing all articles
Browse latest Browse all 9788

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>