I'm currently working on automating some tasks in Microsoft Excel using Office Scripts, and I'm having trouble figuring out how to copy data from one column to another.
I want to copy Date column(D) data to New_Date column(F).
Any help or code snippets would be greatly appreciated. Thank you!
Below code copy Col Date
to Col NewDate
.
function main(workbook: ExcelScript.Workbook) {
// modify table name as needed
let table1 = workbook.getTable("Table1");
let srcRange = table1.getColumn("Date").getRangeBetweenHeaderAndTotal();
let targetCell = table1.getColumn("New_Date").getRangeBetweenHeaderAndTotal().getRow(0);
targetCell.copyFrom(srcRange, ExcelScript.RangeCopyType.all, false, false);
}