Spreadsheet.Recode

This function recodes the specified variable.

Syntax Parameters Return Value
Sub Spreadsheet.Recode( _
    Variable As Integer, _
    OtherValueMode As SpreadsheetRecodeOtherType, _
    OtherValue As Variant, _
    SelectionModeArray As Variant, _
    SelectionStringArray As Variant, _
    DestValueArray As Variant)
  • Variable [in]

Which variable to recode.

Type: Integer

  • OtherValueMode [in]

Integer value specify the method for handling values that do not meet the recode criteria.

Type: SpreadsheetRecodeOtherType

  • OtherValue [in]

Variant value to be used as the replacement value for other values during the recoding.

Type: Variant

  • SelectionModeArray [in]

Integer array which defines the selection condition modes to be used. The available constants for this parameter are: scSelectionConditionIncludeCases, scSelectionConditionIncludeIf, scSelectionConditionExcludeCases, scSelectionConditionExcludeIf. This array will corresponds to the next two parameters, SelectionStringArray and DestValArray.

Type: Variant

  • SelectionStringArray [in]

String array which defines the selection condition expressions to be used while recoding the variable.

Type: Variant

  • DestValueArray [in]

Variant array which contains the replacement values to be used while recoding.

Type: Variant

This function does not return a value.

SVB Example

Recoding data:

Option Base 1
Option Explicit
Sub Main
    'recodes variable 4 of the active spreadsheet,
    'if the condition is not met the cell retains the original value 
    'selection condition = Include If v4 > 3,
    'if the condition is met cell value is changed to 1
    'if you wish to change the cell value of cells which do not meet 
    'the set conditions then use scRecodeOtherValue instead of 'scRecodeLeaveOtherValue and set the third parameter to
    'the value you want these cells to be assigned.
    'For example:
    'ActiveSpreadsheet.Recode(4,scRecodeOtherValue,"9",.....
    ActiveSpreadsheet.Recode(4,scRecodeLeaveOtherValue,"" , _
        Array(scSelectionConditionIncludeIf), _
        Array("v4>3"), _
        Array("1"))
End Sub