script to select the table range dynamically

 function main(workbook: ExcelScript.Workbook) {

  // Get first worksheet (you can change this to getWorksheet("Sheet1"))

  const sheet = workbook.getFirstWorksheet();


  // Get used range dynamically

  const usedRange = sheet.getUsedRange();


  // If table already exists, delete it (optional)

  const tables = workbook.getTables();

  tables.forEach(t => t.delete());


  // Create table from used range, assume headers = true

  const table = workbook.addTable(usedRange, true);


  // Name the table

  table.setName("tbl_Auto");

}

No comments

Theme images by tjasam. Powered by Blogger.