Procedure Spreadsheet::ClearRange(Workbook, Range, Sheet, IncludeCellFormatting)


The procedure Spreadsheet::ClearRange empties the specified range in the specified sheet.

        Workbook,               ! (input) scalar string expression
        Range,                  ! (input) scalar string expression
        [Sheet],                ! (optional) scalar string expression
        [IncludeCellFormatting] ! (optional) scalar binary expression



A scalar string expression representing the Excel or Calc workbook. If this argument ends in .ods, OpenOffice Calc is used. Otherwise, Excel is used.


A scalar string expression containing a reference to the range in the sheet that should be emptied.


The sheet from which the value should be read. Default is the active sheet. If the range is a uniquely named range, no active sheet needs to be set, since named ranges already contain a reference to a sheet.


When set to 1, the formatting of the cell (e.g. font size, color, …) is also cleared. If set to 0, only the value of the cell is cleared.

Return Value

The procedure returns 1 on success, or 0 otherwise. In case of an error the pre-defined AIMMS parameter CurrentErrorMessage contains a description of what went wrong.


  • By calling the procedure Spreadsheet::SetActiveSheet you can set the active sheet, after which the optional sheet argument can be omitted in procedures like this one.

  • A call to this procedure with a specified sheet argument does not change the active sheet, except when the workbook does not have an active sheet yet.

  • Upto AIMMS 3.11 this function was known as ExcelClearRange, which has become deprecated as of AIMMS 3.12.