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
Parameter | Type | Description | |
---|---|---|---|
rangeObj | Object | -> | Range object |
searchValue | Text | -> | Search value |
searchCondition | Object | -> | Object containing search condition(s) |
replaceValue | Text | -> | Replacement value |
Result | Object | <- | 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:
Property | Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
afterColumn | Integer | The 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) | ||||||||
afterRow | Integer | The 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) | ||||||||
all | Boolean | |||||||||
flags | Integer |
$search.flags:=vk find flag use wild cards+vk find flag ignore case | ||||||||
order | Integer |
| ||||||||
target | Integer |
These flags can be combined. For example: |
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