Validating various Google Sheet tabs in real-time

I am currently working on a script for validating localization tests in Google Sheets and I have run into some challenges with the logic. The main goal of the script is to 1) Go through all tabs, 2) Identify the column in row 2 that contains the text "Pass/Fail", and finally, 3) Scan down that column to find and return the rows that have "Fail" indicated.

The function I need to reference is named combined(). Step 1 seems to be on the right track, but step 2 is currently hardcoded and not dynamically searching for the specific text in the row. Step 3, however, has been successfully implemented.

Any assistance on this matter would be greatly appreciated! Thank you in advance for your help :)

https://docs.google.com/spreadsheets/d/1mJfDtAi0hHqhqNB2367OPyNFgSPa_tW9l1akByaTSEk/edit?usp=sharing

    /*The purpose of this function is to cycle through all spreadsheets. 
For each spreadsheet, it will search the second row to locate the column labeled "Pass/Fail". 
Finally, it will identify all the failures in that column and return the respective rows*/

function combined() {

  var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
  var r =[];

  for (var i=0 ; i<sheets.length ; i++){//iterate through all the sheets  
    var sh = SpreadsheetApp.getActiveSheet(); 
    var data = sh.getDataRange().getValues(); // read all data in the sheet
    //r.push("test1"); //Testing to make sure all sheets get cycled through

    /*I need a logic here to determine which column in row two contains "Pass/Fail"*/

      for(i=3;i<data.length;++i){ // iterate row by row and examine data in column A
        //r.push("test2");  //Testing to make sure the all 
        if(data[i][7]=='Fail'){ r.push(data[i])}; // if column 7 contains 'fail' then add it to the list
    }
  }

  return r; //Return row of failed results on all tabs

}

Answer №1

Initially, it retrieves information from column g. This information is then processed to form a 2D array where each element corresponds to a specific sheet index. If a sheet does not contain data in column g, the length of the element is set to 0.

Consider the following scenario:

  • Sheet 0 has no values in column g.
  • Sheet 1 has values in column g with "Fail" at rows 3, 4, and 5.
  • Sheet 2 has values in column g with "Fail" at rows 6, 7, and 8.

The resulting array (return r) would look like this:

[[], [3, 4, 5], [6, 7, 8]]

Example function:

function combined() {
  var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
  var data =[];
  sheets.forEach(function(sheet){
    try {
      data.push(sheet.getRange(3, 7, sheet.getLastRow(), 1).getValues());
    } catch(error) {
      data.push([]);
    }
  });
  var result = [];
  data.forEach(function(innerArray, index1){
    var tempArray = [];
    innerArray.forEach(function(value, index2){
      if (value[0] == "Fail") tempArray.push(index2 + 3);
    });
    result.push(tempArray);
  });
  return result;
}

If there's any confusion or if I've misunderstood your query, I apologize.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The parameter always comes up empty when using $state.go in AngularJS

When trying to pass one parameter using `$stete.go`, I encountered an issue. ROUTER $stateProvider.state('login.signin', { url: '/signin', params: { login_event: '' }, templateUrl: "assets/views/login ...

Creating a dynamic button with Vue

I need help with rendering a button on a Vue instance. I want to be able to click on the button and have another button render with a click event. When I simply mount the button, the function doesn't work. const Hello = { props: ['text'], ...

Utilizing local storage to retain column resize settings in PrimeNG

I am currently working on implementing the order, toggle, and resize (Fit Mode) features on a primeng table. So far, I have managed to update the selectedColumns array for order and toggle, allowing me to save the current user settings. My issue lies with ...

Missing Personal toolbar button on Forge Viewer interface

After completing the tutorial for learning Autodesk Forge, I successfully linked my BIM 360 account to the Forge Viewer. My next goal is to add extensions and have a button on the toolbar that directs to these extensions. However, when following the exten ...

Errors in vue.js conditions

I am currently attempting to validate whether my variable is empty. Despite reviewing my code, I am facing issues with its functionality. My current version of vue.js is 2.5.13 Below you can find the snippet of my code: <template> <div v-if ...

serving files using express.static

I have set up express.static to serve multiple static files: app.use("/assets", express.static(process.cwd() + "/build/assets")); Most of the time, it works as expected. However, in certain cases (especially when downloading many files at once), some fil ...

Is the Facebook AJAX Permissions Dialog displayed outside of a Pop-Up?

I have conducted extensive research but have failed to find a clear answer to my query. Although there is plentiful information on Facebook API AJAX/PHP communication, I am unable to locate an example where the Permission Dialog for an app (showPermissionD ...

This is the command that includes the line "test": "tsc && concurrently "karma start karma.conf.js""

When running npm run test with the line "test": "tsc && concurrently \"karma start karma.conf.js\"" in my package.json, I encounter the error message 'Error: no test specified'. Can someone guide me on how to resolve this issue? ...

Having trouble navigating to the bottom of a VUEJS app?

I've been working on developing a chatbot app that utilizes a REST API to stream content. While the functionality of the app is running smoothly, I have encountered an issue with the scroll to bottom feature. Instead of automatically scrolling to disp ...

Tips for displaying "No Results" without causing any lag in the browser

I'm encountering difficulty trying to implement a simple feature without resorting to a "messy" solution. The performance is suffering, and I am certain it's not done in a "professional" manner. What I desire is straightforward – displaying a ...

JavaScript Function Not Executed in Bottom Section

I've implemented AngularJS includes in my project. Below is the code snippet from my index.html: <!DOCTYPE html> <html ng-app=""> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"> ...

Determine the cost for every individual line

I need help figuring out how to calculate the price for each row. Whenever I choose a quantity, it's showing the same price for both rows. Check out my demo here: https://jsfiddle.net/keyro/fw8t3ehs/2/ Thank you in advance! HTML: <table class=" ...

What is the method for triggering the output of a function's value with specified parameters by clicking in an HTML

I am struggling to display a random number output below a button when it is clicked using a function. <!DOCTYPE html> <html> <body> <form> <input type="button" value="Click me" onclick="genRand()"> </form> <scri ...

What is the best way to create a seamless Asynchronous loop?

Adhering to the traditional REST standards, I have divided my resources into separate endpoints and calls. The primary focus here revolves around two main objects: List and Item (with a list containing items as well as additional associated data). For ins ...

Module.exports causing keyword errors in eslint

Encountering some unusual errors from eslint CI regarding my jest.config.js file. 1:1 error Rule 'no-empty-label' has been replaced by: no-labels no-empty-label 1:1 error Rule 'no-reserved-keys' has been replaced ...

Dealing with bulkWrites in Mongoose and MongoDB: how to handle cast errors with finesse

When importing data into my app's database using MongoDB's bulkWrite operation, I encounter a challenge. The data may contain errors as it comes from an external source. To maintain the integrity of my data, I need to update my collection while s ...

An in-depth guide on incorporating an Editor into a Reactjs project

Currently, I am working with Reactjs and using the Nextjs framework. My goal is to integrate the "Tinymce" editor into my project and retrieve the editor value inside a formsubmit function. How can I achieve this? Below is my current code: const editor = ...

What is the purpose of returning a function in a React Hook?

Currently, I am incorporating Material-UI components into my project and have implemented the AutoComplete component in my application. While exploring an example provided by the Material-UI team, I stumbled upon a fascinating instance of using Ajax data ...

Efficiently pinpointing the <div> element with precision using jQuery

I am building an interactive quiz for users of my app. The questions are table based, and can be answered "yes," "no," or "maybe." If the user answers "no" or "maybe," I would to slide open an informational panel that lives beneath the table. Here is the ...

Tips on sending the total value of a form to a PHP script

Looking for help with a PHP script to calculate the sum of checked checkboxes with corresponding numeric values. For example, if checkbox 1 = 80; checkbox 2 = 21; and checkbox 3 = 15, and the user checks checkboxes 2 and 3, the PHP should output 36. I hav ...