Skip to main content
Version: 20 R7 BETA

VP Find

VP Find ( rangeObj : Object ; searchValue : Text ) : Object
VP Find ( rangeObj : Object ; searchValue : Text ; searchCondition : Object } ) : Object
VP Find ( rangeObj : Object ; searchValue : Text ; searchCondition : Object ; replaceValue : Text ) : Object

ParameterTypeDescription
rangeObjObject->Range object
searchValueText->Search value
searchConditionObject->Object containing search condition(s)
replaceValueText->Replacement value
ResultObject<-Range object

Description

The VP Find command searches the rangeObj for the searchValue. Optional parameters can be used to refine the search and/or replace any results found.

In the rangeObj parameter, pass an object containing a range to search.

The searchValue parameter lets you pass the text to search for within the rangeObj.

You can pass the optional searchCondition parameter to specify how the search is performed. The following properties are supported:

PropertyTypeDescription
afterColumnIntegerThe number of the column just before the starting column of the search. If the rangeObj is a combined range, the column number given must be from the first range. Default value: -1 (beginning of the rangeObj)
afterRowIntegerThe number of the row just before the starting row of the search. If the rangeObj is a combined range, the row number given must be from the first range. Default value: -1 (beginning of the rangeObj)
allBoolean
  • True - All cells in rangeObj corresponding to searchValue are returned
  • False - (default value) Only the first cell in rangeObj corresponding to searchValue is returned
  • flagsInteger
    vk find flag exact matchThe entire content of the cell must completely match the search value
    vk find flag ignore caseCapital and lower-case letters are considered the same. Ex: "a" is the same as "A".
    vk find flag noneno search flags are considered (default)
    vk find flag use wild cardsWildcard characters (*,?) can be used in the search string. Wildcard characters can be used in any string comparison to match any number of characters:
  • * for zero or multiple characters (for example, searching for "bl*" can find "bl", "black", or "blob")
  • ? for a single character (for example, searching for "h?t" can find "hot", or "hit"
  • These flags can be combined. For example: $search.flags:=vk find flag use wild cards+vk find flag ignore case
    orderInteger
    vk find order by columnsThe search is performed by columns. Each row of a column is searched before the search continues to the next column.
    vk find order by rowsThe search is performed by rows. Each column of a row is searched before the search continues to the next row (default)
    targetInteger
    vk find target formulaThe search is performed in the cell formula
    vk find target tagThe search is performed in the cell tag
    vk find target textThe search is performed in the cell text (default)

    These flags can be combined. For example:$search.target:=vk find target formula+vk find target text

    In the optional replaceValue parameter, you can pass text to take the place of any instance of the text in searchValue found in the rangeObj.

    Returned Object

    The function returns a range object describing each search value that was found or replaced. An empty range object is returned if no results are found.

    Example 1

    To find the first cell containing the word "Total":

    var $range;$result : Object

    $range:=VP All("ViewProArea")

    $result:=VP Find($range;"Total")

    Example 2

    To find "Total" and replace it with "Grand Total":

    var $range;$condition;$result : Object

    $range:=VP All("ViewProArea")

    $condition:=New object
    $condition.target:=vk find target text
    $condition.all:=True //Search entire document
    $condition.flags:=vk find flag exact match

    // Replace the cells containing only 'Total' in the current sheet with "Grand Total"


    $result:=VP Find($range;"Total";$condition;"Grand Total")

    // Check for empty range object
    If($result.ranges.length=0)
    ALERT("No result found")
    Else
    ALERT($result.ranges.length+" results found")
    End if