Let's say you pass an array of values to be processed to a custom function, and you want to loop through them. In these examples, we'll just go through each value and sum it if it is a number.
In this case, an index is used for each dimension of the values, using the .length property of the array to loop through the rows, then the columns, of the passed values.
This will call a function for each member of an array, passing the value found at each array element. We can write an anonymous function which .forEach will call to do something with each Array element. Since this is a two dimensional array, the outer forEach loop calls the function with a single dimension array representing a single row of values, and the inner loop calls a second anonymous function passing the value of the cell at each element of the row.
For more like this, see From VBA to Google Apps Script . Why not join our forum,follow the blog or follow me on twitter to ensure you get updates when they are available.
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > From VBA to Google Apps Script >