Forum Discussion

StefanMogyorosi's avatar
StefanMogyorosi
Copper Contributor
Jun 01, 2023
Solved

Excel script run with error since today (Range Delete)

I have a script that manipulates an excel table by deleting columns and adding new ones. The script that yesterday worked correctly today stops working and i get these errors:

Range delete: You cannot perform the requested operation.
Range insert: You cannot perform the requested operation.

To be sure I tried the example script from the manual:

 

 

/**
 * This sample creates a sample range, then deletes
 * "A1" using different DeleteShiftDirection values.
 */
function main(workbook: ExcelScript.Workbook) {
  // Add sample data to better visualize the delete changes.
  const currentSheet = workbook.getActiveWorksheet();
  currentSheet.getRange("A1:D4").setValues([
    [1,2,3,4],
    [5,6,7,8],
    [9,10,11,12],
    [13,14,15,16]]);

  // Delete A1 and shift the cells from the right to fill the space.
  // The value being deleted is 1.
  currentSheet.getRange("A1").delete(ExcelScript.DeleteShiftDirection.left);

  // Delete A1 and shift the cells from the bottom to fill the space.
  // The value being deleted is 2.
  currentSheet.getRange("A1").delete(ExcelScript.DeleteShiftDirection.up);

  // Log the sample range. The values should be:
  /*
    5, 3, 4, "",
    9, 6, 7, 8,
    13, 10, 11, 12,
    "", 14, 15, 16
  */
  console.log(currentSheet.getRange("A1:D4").getValues()); 
}

 

 

And I got the same error. Maybe someone knows what happened from yesterday and how to solve it.

Resources