I am attempting to develop a custom function similar to the following:
function calculateRange(startCell, endCell) {
// Perform calculations based on the range defined by the provided arguments
return calculatedResult;
}
The variable startCell
refers to a specific cell like B1
, and endCell
is another cell reference like B2
. I want these variables to reference a range in a different worksheet within the same Google Sheets document, such as B1:B2 in Sheet2
.
When I leverage the getRange()
method, using the argument "B1:B2"
works fine for accessing the range. However, things break down in this scenario:
var combinedRange = startCell + ':' + endCell;
var targetRange = sheet2.getRange(combinedRange);
I believe there is a syntax issue that is causing the function to fail in recognizing combinedRange
as a valid range. I’m feeling quite lost on this issue. Any assistance, suggestions for good syntax reference resources, or tutorials would be greatly appreciated, including solutions to my challenge.