You can try this. Enter in the Spreadsheet in the range A:A a value from 1 to 16.
Last active
May 24, 2018 13:36
-
-
Save oshliaer/ac66acaf7315870d6c578152229d12a2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| var DATASHEETID = '1gnNuHGReX5Bwc4CbgNcT8mol7Q97TSm9LqkGqhXnazE'; | |
| function onEdit(e) { | |
| try{ | |
| if(!e || ! e.range) return; | |
| if(e.range.columnStart === 1){ | |
| var data = getData(); | |
| var entry = getEntryByIndex(data, 0, e.value); | |
| Logger.log(entry); | |
| if(entry.length) | |
| SpreadsheetApp.getActiveSheet().getRange(e.range.rowStart, 2, 1, entry.length).setValues([entry]); | |
| } | |
| }catch(err){ | |
| SpreadsheetApp.getActiveSpreadsheet().toast(err.message, 'Error!!1'); | |
| } | |
| } | |
| function getData(){ | |
| return SpreadsheetApp.openById(DATASHEETID).getRange('Sheet1!A:H').getValues(); | |
| } | |
| function getEntryByIndex(data, col, index){ | |
| for(var i = 0; i < data.length; i++){ | |
| if(data[i][col] == index) | |
| return data[i]; | |
| } | |
| return []; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment