Using Office Scripts (in Excel), I'd like to apply a formula to a new column in which the formula contains the function for finding the maximum value of an adjacent column. The number of data points collected varies from experiment to experiment, so I don't want to set finite bounds for finding the maximum of the adjacent column (i.e. MAX(G2:G10)).
I'd like to ideally create a variable for the number of rows so that I could then calculate the maximum of the column, despite the changing number of data points collected across experiments, such as MAX(G2:G(numrows)).
I've tried applying something along the lines of:
let rowCount = range.getRowCount();
const numrows = rowCount
selectedSheet.getRange("H1:H2").setFormulasLocal([["Air Flow (%)"], ["=(G2/MAX($G$2:$G(numrows)))*100"]]);
I know that this syntax isn't correct, as it just results in an error (#NAME?), and was wondering if there were any suggestions on which variable types could make this work (or other approaches all together).
Thanks in advance!