Forum Discussion
MadPrince
Oct 05, 2023Copper Contributor
Excel Script, input data in blank column/ rows
I have this problem in my excel script formula. It is working fine. The only problem is that I need to input starting row... And if for example there is data or the column/row is not empty, it will...
SergeiBaklan
Oct 06, 2023Diamond Contributor
- MadPrinceOct 06, 2023Copper Contributor
This did the trick.. thank you.
- SergeiBaklanOct 07, 2023Diamond Contributor
Or
function main(workbook: ExcelScript.Workbook) { const arrayvar = workbook .getTable("Table1") .getRangeBetweenHeaderAndTotal() .getValues() const sheet = workbook.getActiveWorksheet() let rangeToFill: ExcelScript.Range = sheet .getCell( sheet .getUsedRange() .getLastRow() .getRowIndex(), 0) .getResizedRange(0, arrayvar[0].length - 1) arrayvar.map(x => { rangeToFill = rangeToFill.getRowsBelow(1); rangeToFill.setValues(Array.of(x)) } ) } - SergeiBaklanOct 06, 2023Diamond Contributor
MadPrince , you are welcome.
In attached file I tried to imitate entire script
function main(workbook: ExcelScript.Workbook) { const arrayvar = workbook .getTable("Table1") .getRangeBetweenHeaderAndTotal() .getValues() const sheet = workbook.getActiveWorksheet() const rangeToFill = sheet .getCell( sheet .getUsedRange() .getLastRow() .getRowIndex() + 1, 0) .getResizedRange(arrayvar.length, arrayvar[0].length - 1) for ( let i = 0; i < arrayvar.length; i++) { rangeToFill .getRow(i) .setValues( Array.of( arrayvar[i]) ) } }