I've been working on a small search tool in Google Sheets. This is a project I have created to learn about GS and hopefully take some of my learns into work.
Munkey has been helping me over the last couple of weeks develop my skills and understanding.
I have linked below my "Database" and search tool.
Database - https://docs.google.com/spreadsheets/d/1K53LOopwAJuOVPJ5RXgpmEO7L3JPHnW5Fx2qp6_3kqo/edit?usp=sharing
Search tool - https://docs.google.com/spreadsheets/d/1mY13e-75dBYfKgkjV8dFFFEvxC838nGNxPrUdusc0PA/edit?usp=sharing
I have the Script below "pushing" data from the Database to the search tools databases to be utilised by the Vlookup function.
function getOvenDataV4(){
var ui = SpreadsheetApp.getUi();
ui.createMenu('Export Data')
.addItem('Export Oven Data Now', 'getOvenDataV4')
.addToUi();
var settingsSheetName = "oven_settings";
/* DO NOT EDIT BELOW THIS LINE */
var ss = SpreadsheetApp.getActiveSpreadsheet();
var settings = ss.getSheetByName(settingsSheetName); // this loads the settings sheet
var targetSheet = settings.getRange("C2").getValue(); // this gets the target sheet name from the settings sheet
var sSheets = settings.getRange("B2:B").getValues(); // this gets the values in column B in settings, the source sheet names
var sourceSheets = []; // this is where we will store the sheet names once we make sure they are not blank
// this loops makes sure that there is data in Column B in the settings sheet, if there is, push it to sourceSheets Array
for(var i = 0; i < sSheets.length;i++){
if(sSheets[i][0]!=""){
sourceSheets.push(sSheets[i]);
}
}
var dKeys = settings.getRange("A2:A").getValues(); // This gets the values of column A in settings, the spreadsheet keys/IDs
var sKeys = []; // this is where we will store the ID's/keys that are not blank for later
// this loop makes sure that column A, the spreadsheet IDs/keys,not blank, if they are not blank. Lets push them into the sKeys Array
for(var i = 0; i < dKeys.length;i++){
if(dKeys[i][0]!=""){
sKeys.push(dKeys[i]);
}
}
var data = [];
for (var i= 0; i<sourceSheets.length;i++){
var values = ss.getSheetByName(sourceSheets[i]).getDataRange().getValues();
for (var x = 1;x < values.length; x++){
if(values[x][0]!= ""){
data.push(values[x]);
}
}
}
// below loops through all your keys, opens that sheet by ID, which we have, and opens the target sheet, which we have and writes the data
for (var i = 0; i< sKeys.length;i++){
var tss = SpreadsheetApp.openById(sKeys[i]);
var target = tss.getSheetByName(targetSheet);
var range = target.getRange(2,1, data.length, data[0].length); target.getRange(2,1,target.getLastRow()-1,target.getLastColumn()).clearContent();
range.setValues(data);
}
}
Munkey made some comments that are added to the above snippit to help me understand how it all worked. The script works fantastic and as intended. However, it wont pull the data through from my =image("") formula in column "H".
Can anyone offer any help on how to adapt the above script to pull the =Image("") formula to the search tool? Similar to how =importrange does it?
I've tried to search this, including the google dev site, and a variety of different methods to do this using the getFormula and getFormulas methods, but nothing has seemed to work so far. Most likely I'm just using them wrong :)