ExcelScript.SearchCriteria interface

Represents the search criteria to be used.

Remarks

Examples

/**
 * This script searches for the next instance of the text "TK" on the current worksheet.
 * It then selects that cell and removes "TK" and all formatting from the cell.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the used range on the current worksheet.
  let range = workbook.getActiveWorksheet().getUsedRange();

  // Get the next cell that contains "TK".
  let tkCell = range.find("TK", {
    completeMatch: true, /* Don't match if the cell text only contains "TK" as part of another string. */
    matchCase: false,
    searchDirection: ExcelScript.SearchDirection.forward /* Start at the beginning of the range and go to later columns and rows. */
  });

  // Set focus on the found cell.
  tkCell.select();

  // Remove the "TK" text value from the cell, as well as any formatting that may have been added.
  tkCell.clear(ExcelScript.ClearApplyTo.all);
}

Properties

completeMatch

Specifies if the match needs to be complete or partial. A complete match matches the entire contents of the cell. A partial match matches a substring within the content of the cell (e.g., cat partially matches caterpillar and scatter). Default is false (partial).

matchCase

Specifies if the match is case-sensitive. Default is false (case-insensitive).

searchDirection

Specifies the search direction. Default is forward. See ExcelScript.SearchDirection.

Property Details

completeMatch

Specifies if the match needs to be complete or partial. A complete match matches the entire contents of the cell. A partial match matches a substring within the content of the cell (e.g., cat partially matches caterpillar and scatter). Default is false (partial).

completeMatch?: boolean;

Property Value

boolean

matchCase

Specifies if the match is case-sensitive. Default is false (case-insensitive).

matchCase?: boolean;

Property Value

boolean

searchDirection

Specifies the search direction. Default is forward. See ExcelScript.SearchDirection.

searchDirection?: SearchDirection;

Property Value