Skip to main content

Create Menu in Google sheet and link to another sheet

Create a Custom Menu to link another sheet
In google sheet

Custom Menu in Google Sheet

 

Create a custom menu and link to another sheet by using the app script editor.

For Custom menu items  use simple trigger function, which is  onOpen() .

To update onOpen()  and add new menu items in the menu bar do the following.

 

script editor in google sheet

·         In the menu bar click on tools - > script editor add following script.  

·         You can add your desired menu item name as per your requirement.

·         Change the Menu name as per your requirement (i.e.; ‘My Data’ ‘Progress-Report’, ‘Sales’. ‘Max’, ‘Rocky’)

 

function onOpen() {

  var ui = SpreadsheetApp.getUi();

  ui.createMenu('MyData')

      .addItem('Progress-report', 'menu1')

      .addSeparator()

      .addSubMenu(ui.createMenu('Sales')

          .addItem('Max', 'menu2')

          .addItem('Rocky', 'menu3'))

      .addToUi();

  }


Once Menu created in the menu bar, assign Links for each menu adding the below script. 

Note: Paste your target sheet url in the place of 'PASTE YOUR URL HERE' text

Change the user interface name in the script as per your requirement. 



function menu1() {

  var selection = SpreadsheetApp.getActiveSheet().getActiveCell().getValue();

    var html = "<script>window.open('PASTE YOUR URL HERE');google.script.host.close();</script>";

    var userInterface = HtmlService.createHtmlOutput(html);

    SpreadsheetApp.getUi().showModalDialog(userInterface, 'Progress Report');

}


function menu2() {

  var selection = SpreadsheetApp.getActiveSheet().getActiveCell().getValue();

    var html = "<script>window.open('PASTE YOUR URL HERE');google.script.host.close();</script>";

    var userInterface = HtmlService.createHtmlOutput(html);

    SpreadsheetApp.getUi().showModalDialog(userInterface, 'Max');

}


function menu2() {

  var selection = SpreadsheetApp.getActiveSheet().getActiveCell().getValue();

    var html = "<script>window.open('PASTE YOUR URL HERE');google.script.host.close();</script>";

    var userInterface = HtmlService.createHtmlOutput(html);

    SpreadsheetApp.getUi().showModalDialog(userInterface, 'Rocky');

}


Watch the video for more details : 

Comments

Popular posts from this blog

Create a button in google sheet and link to multiple sheets through the script editor code

To create a button in google sheet and link to another sheet  through the script, just follow the below steps. First, open a google sheet, click on the main menu, Insert - Drawing Select a Shape and desired Button and drag and create button   Now, once button created click on the three dots on the top right of the button Click on Assign script (any desired letters)    Now go to tool - script editor and delete existing codes. and paste the following code :  function PC() {   var selection = SpreadsheetApp.getActiveSheet().getActiveCell().getValue();     var html = "<script>window.open(' paste url here');google.script.host.close();</script>";     var userInterface = HtmlService.createHtmlOutput(html);     SpreadsheetApp.getUi().showModalDialog(userInterface, 'Petty Cash'); } Make necessary changes as per your target sheet requirement.  For more details  watch the video: - 

Get image file links from google drive to Google Sheet cell

  By using formulas, scripts and buttons we can prepare a complete staff records form. In this form we can assign buttons such as entering the data to the data sheet, search details  and clear the form by using script and buttons.  Also, get image file url links in google sheet  cell to display or enter the data along with other other details.  We have detailed script and formulas  below to use this form effectively to maintain the staff records.  SCRIPT function   GdriveFiles () {      const   folderId  =  'YOUR GOOGLE DRIVE FOLDER LINK HERE'    const   folder  =  DriveApp . getFolderById ( folderId )    const   files  =  folder . getFiles ()    const   source  =  SpreadsheetApp . getActiveSpreadsheet ();    const   sheet  =  source . getSheetByName ( 'images' );    const   data  =...

Link image to an url in googlesheet

To create a link to an image and access external url in googlesheet is quit easy by using a simple app script. This is very usefull for creating multiple links to different websites or clients. Use following script : - function   imageLink () {    var   html  =  "<script>window.open('https://tekrayz.blogspot.com/');google.script.host.close();</script>" ;    var   userInterface  =  HtmlService . createHtmlOutput ( html );     SpreadsheetApp . getUi (). showModalDialog ( userInterface ,  'Loading...' ); } Also watch video - >