Last active
May 24, 2018 13:36
-
-
Save pozhidaevak/facb47e14e73290f2cd853771d25c984 to your computer and use it in GitHub Desktop.
Google sheets: fast creation of URL from cell by template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Just change 22nd string to your template :-D | |
// This script adds "URL" menu to google sheet with one intem "create URL". | |
// You need select cell range and click on the menu item in order to make links from your cells. | |
// It can create links by template 123 => https://example.com/browse/123/. | |
var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
function onOpen() { | |
var menu = [{name: "create URL", functionName: "createURL"}]; | |
ss.addMenu("URL", menu); | |
} | |
function createURL() { | |
var aRange = ss.getActiveRange() | |
var numRows = aRange.getNumRows(); | |
var numCols = aRange.getNumColumns(); | |
for (var i = 1; i <= numRows; i++) { | |
for (var j = 1; j <= numCols; j++) { | |
var currentValue = aRange.getCell(i,j).getValue(); | |
//String with template | |
aRange.getCell(i,j).setValue('=HYPERLINK("https://example.com/browse/'+currentValue+'","'+currentValue+'")'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment