I'm making an spreadsheet in google sheets where I've got several links to pre-filled google forms https://docs.google.com/forms . I added a 'button' in the spreadsheet which, when you click it, navigates to the cell containing the right link to the pre-filled form (16 cells to the right of the current active cell), which looks like;
function GoToSite(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Returns the active cell
var cell = sheet.getActiveCell();
cell.offset(0,16).activate();
};
However, I don't manage to get the spreadsheet to open this link. I know that in a normal excel file, you would use something looking like;
Sub openwebpage ()
...
End Sub
And you would use "FollowHyperlink"/ "create an IE object" / ".Navigate" or maybe even "Sendkeys" (if you enter alt+enter when the cell containing the pre-filled link is selected, this opens the webpage). But all these options are in combination with sub .. end sub and I don't manage the macro to recognise this. It seems to only work with
function example (){
...
};
Maybe I'm doing something totally wrong. Is there someone who would know how to open the link in the cell by using macros? Or how to use "Sub ... End Sub" in an google sheet?
Thanks