Home > database >  Search bar google sheet menu (add-on app script)
Search bar google sheet menu (add-on app script)

Time:06-10

What I want to do:

Using App Script in Google Sheet, I want to insert a search bar inside a custom menu, with auto-completion on a custom defined array (like ["potato", "apple"], and typing p should suggest potato)

How would it look:

enter image description here

What I tried

Well, I looked through documentation but it doesn't seem to be feasible. Also searched online without success.

CodePudding user response:

What is suggested in the comments is correct. As another alternative you can add a custom menu with options over the toolbar, for example the script can create the button when opening the Sheet clicking on it would provide you a pop-up window.

function onOpen() {
  var SS = SpreadsheetApp.getActiveSpreadsheet();
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('Find me')
    .addItem('Search for me', 'searchme')
    .addToUi();
};

function searchme(){
  var searchId = Browser.inputBox('Enter name', Browser.Buttons.OK_CANCEL);
  if (searchId === "") {
    Browser.msgBox('Name ID is invalid');
    return;
  }
  getSearch(searchId, true); 
};

You would get this window when clicking or running the tool "Find Me" at the tool bar:

enter image description here

From there you can start building a code to make some searches, it is the closest option available to something similar to what you need. There is a thread where this suggestion has been provided with a sample code that you can also review.

Other than these alternatives, it could be an excellent idea or option that can be implemented for AppScript, you this feature for the feature here:

  • Related