I have S1 and S2 sheet;
S1 sheet -> S1 has two unique values that I need to filter and copy/paste visible rows to the next sheet, like ABC_1 sheet and ABC_2
S2 sheet -> S2 has the same unique values, I need to filter and paste ABC_1 last row
function main(workbook: ExcelScript.Workbook) {
let prof_Cenr = workbook.getWorksheet("Profit");
// Set range AF15 on profit_Ce
prof_Cen.getRange("AF15").setValue("");
let selectedSheet = workbook.getActiveWorksheet();
// Set range AF3 on selectedSheet
// Toggle auto filter on selectedSheet
selectedSheet.getAutoFilter().apply(selectedSheet.getRange("3:3"));
// Apply custom filter on selectedSheet
selectedSheet.getAutoFilter().apply(selectedSheet.getAutoFilter().getRange(), 31, { filterOn: ExcelScript.FilterOn.custom, criterion1: "=*ABC DEBT PRO*" });
let I_ABC_DEBT___Output = workbook.getWorksheet("I_DEBT _ Output");
// Paste to range offset by 1 row(s) and 0 column(s) from edge range obtained by extending down from range A4 on I_AGE_DEBT___Output from range 5:9 on selectedSheet
I_AGED_DEBT___Output.getRange("A4").getRangeEdge(ExcelScript.KeyboardDirection.down).getOffsetRange(1, 0).copyFrom(selectedSheet.getRange("5:9"), ExcelScript.RangeCopyType.all, false, false);
// Clear auto filter on selectedSheet
selectedSheet.getAutoFilter().clearCriteria();
// Apply custom filter on selectedSheet
selectedSheet.getAutoFilter().apply(selectedSheet.getAutoFilter().getRange(), 31, { filterOn: ExcelScript.FilterOn.custom, criterion1: "=*ISPEC DEBT*" });
let I_SPECIFIC_BAD_DEBT_Output = workbook.getWorksheet("I_SPEC_DEBT_Output");
// Paste to range A11 on I_SPEC_DEBT_Output from range 10:12 on selectedSheet
I_SPEC_DEBT_Output.getRange("A11").copyFrom(selectedSheet.getRange("10:12"), ExcelScript.RangeCopyType.all, false, false);
// Clear auto filter on selectedSheet
selectedSheet.getAutoFilter().clearCriteria();
}
Need advise on how to copy visible rows and paste to the last row of the next sheet.