Not sure it can be done but here is the question. I have a sheets app with multiple sheets. Sheet 1 contains data as follows:
String Descriptor | Value 1 | Value 2
Sheet 2 is working formulas. Cell D37 in this example has a reference to 'Sheet1'!A14
On sheet 2, column E I'd like to reference back to 'Sheet1'!A16
If I pass the string value of "D37" I can find the cell and then manipulate things and return the proper data. I can't however get things to work when I try to get the cell address passed by the function I get "range not found" errors.
Sheet 2 reference is '=INDIRECT(myFunction(D37))
function myFunction(piNameCell) { //piNameCell has the reference to D37
var ss = SpreadsheetApp;
var sheet = ss.getActiveSheet().getRange(piNameCell); // Like this it crashes
//var sheet = ss.getActiveSheet().getRange("D37"); //This works
var sheetRef = sheet.getFormula();
//remove the leading '=' sign
sheetRef = sheetRef.substring(1);
//find the !
var bangIndex = sheetRef.indexOf("!");
//change the column to 'E'
sheetRef = sheetRef.substring(0,bangIndex+1) + "E" + sheetRef.substring(bangIndex+2)
return sheetRef;
}