Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140220

Google Sheets Script - How to search array for product 'item type' and send to sheet with name of the 'Item Type'?

$
0
0

first time post so be gentle ;-;

I'm putting together a Google sheet to assemble custom drone builds from a parts list. The master parts list and compiler are on the MASTER sheet. I've got my script to assemble an array of the rows based on item type (alphabetical order).

I want to make it so that on the button press, the script assembles and sorts an array, then copies the rows to their item type page so the compiler can make a dropdown menu (menu part exists and works). Just need to populate the item type pages with the data from the master list.

My idea was to run an if statement e.g if string matches, write array string to empty range on matched sheet. Is this possible or is there a much simpler way to do this?

Any help is greatly --appreciated-- (needed desperately)!

/** @customFunction
What I want the script to do:
Read Column 1 from A26:A100 or lookahead for end of list
If current cell contains Sheet Name, copy row to corresponding sheet.
*/

/** function myFunction() {
Browser.msgBox('You clicked it!');
}
@customFunction
*/ 

/** var PDB = app.getActiveSpreadsheet().getSheetByName("PDB"); //Target sheet for PDB
var VTX = app.getActiveSpreadsheet().getSheetByName("VTX"); //Target sheet for VTX
var FRAME = app.getActiveSpreadsheet().getSheetByName("FRAME"); //Target sheet for FRAME
var MOTOR = app.getActiveSpreadsheet().getSheetByName("MOTOR"); //Target sheet for MOTOR
var FPVCAM = app.getActiveSpreadsheet().getSheetByName("FPVCAM"); //Target sheet for FPVCAM
var AIOFC = app.getActiveSpreadsheet().getSheetByName("AIO FC"); //Target sheet for AIO FC
var ESC = app.getActiveSpreadsheet().getSheetByName("ESC"); //Target sheet for ESC
var PROPS = app.getActiveSpreadsheet().getSheetByName("PROPS"); //Target sheet for PROPS

var itemType = activeSheet.getRange(i, 1).getValue();
*/


function sortscript() {
Logger.clear(); 
var app = SpreadsheetApp                                       //selects app
var activeSheet = app.getActiveSpreadsheet().getActiveSheet(); //selects Spreadsheet and Sheet
var itemListArr = [];

for(var i=27;i<=58;i++){
 var itemListGet = activeSheet.getRange(i, 1, 1, 7).getValues();   //Create Array of Items and rows
itemListArr.push(itemListGet);
 itemListArr.sort();                                               //Groups by item type alphabetically
}


if(itemListArr.indexOf("PDB") > -1) {
activeSheet.getActiveCell()
Logger.log()                        //Does nothing right now ik
}



}

Apologies for this horrific clusterf***. Any help is greatly appreciated


Viewing all articles
Browse latest Browse all 140220

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>