Forum Discussion

dasa7's avatar
dasa7
Copper Contributor
May 31, 2023
Solved

Script run with error (Range delete)

Hello, I have been running the same script for a few weeks, but since today it is running with the following error: Line 4: Range delete: You cannot perform the requested operation.   When I try ...
  • NikolinoDE's avatar
    May 31, 2023
    The error "Range delete: You cannot perform the requested operation" in line 4 indicates that the delete operation is not allowed on the specified range. This error can occur due to several reasons:

    Protection: Check if the worksheet or specific range you are trying to delete is protected. If it is protected, you need to unprotect it before performing the delete operation. You can use the worksheet.getProtection().unprotect() method to remove the protection.

    Merged cells: If the range you are trying to delete contains merged cells, deleting the range may not be allowed. In such cases, you can try unmerging the cells first using the range.unmerge() method and then perform the delete operation.

    Invalid range: Verify that the range you are specifying ("B:B", "F:F", "G:G", etc.) is correct and valid. Make sure it does not include any extra characters or spaces.

    Compatibility: It's possible that the delete operation you are trying to perform is not supported in Excel 2016. Check the documentation or specific limitations of the Excel version you are using to see if there are any restrictions on deleting ranges.

    You can try modifying your code to handle these scenarios and ensure that the range you are trying to delete is valid and allowed for deletion.

Resources