Spreadsheet.SortData

This function sorts the specified variables in the spreadsheet by ascending, numeric order.

Syntax Parameters Return Value
Sub Spreadsheet.SortData( _
    Key1 As Variant, _
    Optional Order1 As Variant, _
    Optional By1 As Variant, _
    Optional Key2 As Variant, _
    Optional Order2 As Variant, _
    Optional By2 As Variant, _
    Optional Key3 As Variant, _
    Optional Order3 As Variant, _
    Optional By3 As Variant, _
    Optional Key4 As Variant, _
    Optional Order4 As Variant, _
    Optional By4 As Variant, _
    Optional Key5 As Variant, _
    Optional Order5 As Variant, _
    Optional By5 As Variant, _
    Optional Key6 As Variant, _
    Optional Order6 As Variant, _
    Optional By6 As Variant, _
    Optional Key7 As Variant, _
    Optional Order7 As Variant, _
    Optional By7 As Variant)
  • Key1 [in]

Which variable to sort.

Type: Variant

  • Order1 [in,optional]

Integer value specifying sorting order. The following constants can be used as arguments for this parameter: scSortAscending, scSortDescending. Note that this parameter defaults to scSortAscending.

Type: Variant

  • By1 [in,optional]

The sorting criteria. The following constants can be used as arguments for this parameter: scSortByNumeric, scSortByText. Note that this parameter defaults to scSortByNumeric.

Type: Variant

  • Key2 [in,optiona]

Which variable to sort.

Type: Variant

  • Order2 [in,optional]

Integer value specifying sorting order. The following constants can be used as arguments for this parameter: scSortAscending, scSortDescending. Note that this parameter defaults to scSortAscending.

Type: Variant

  • By2 [in,optiona]

The sorting criteria. The following constants can be used as arguments for this parameter: scSortByNumeric, scSortByText. Note that this parameter defaults to scSortByNumeric.

Type: Variant

  • Key3 [in,optional]

Which variable to sort.

Type: Variant

  • Order3 [in,optional]

Integer value specifying sorting order. The following constants can be used as arguments for this parameter: scSortAscending, scSortDescending. Note that this parameter defaults to scSortAscending.

Type: Variant

  • By3 [in,optional]

The sorting criteria. The following constants can be used as arguments for this parameter: scSortByNumeric, scSortByText. Note that this parameter defaults to scSortByNumeric.

Type: Variant

  • Key4 [in,optional]

Which variable to sort.

Type: Variant

  • Order4 [in,optional]

Integer value specifying sorting order. The following constants can be used as arguments for this parameter: scSortAscending, scSortDescending. Note that this parameter defaults to scSortAscending.

Type: Variant

  • By4 [in,optional]

The sorting criteria. The following constants can be used as arguments for this parameter: scSortByNumeric, scSortByText. Note that this parameter defaults to scSortByNumeric.

Type: Variant

  • Key5 [in,optional]

Which variable to sort.

Type: Variant

  • Order5 [in,optional]

Integer value specifying sorting order. The following constants can be used as arguments for this parameter: scSortAscending, scSortDescending. Note that this parameter defaults to scSortAscending.

Type: Variant

  • By5 [in,optional]

The sorting criteria. The following constants can be used as arguments for this parameter: scSortByNumeric, scSortByText. Note that this parameter defaults to scSortByNumeric.

Type: Variant

  • Key6 [in,optional]

Which variable to sort.

Type: Variant

  • Order6 [in,optional]

Integer value specifying sorting order. The following constants can be used as arguments for this parameter: scSortAscending, scSortDescending. Note that this parameter defaults to scSortAscending.

Type: Variant

  • By6 [in,optional]

The sorting criteria. The following constants can be used as arguments for this parameter: scSortByNumeric, scSortByText. Note that this parameter defaults to scSortByNumeric.

Type: Variant

  • Key7 [in,optional]

Which variable to sort.

Type: Variant

  • Order7 [in,optional]

Integer value specifying sorting order. The following constants can be used as arguments for this parameter: scSortAscending, scSortDescending. Note that this parameter defaults to scSortAscending.

Type: Variant

  • By7 [in,optional]

The sorting criteria. The following constants can be used as arguments for this parameter: scSortByNumeric, scSortByText. Note that this parameter defaults to scSortByNumeric.

Type: Variant

This function does not return a value.

SVB Example

Sorting variables:

Option Base 1
Option Explicit
Sub Main
    Dim spr As Spreadsheet
    'assigns the active spreadsheet to the object spr
    Set spr = ActiveSpreadsheet
    'sorts the cell values in variable 1 in ascending order
    'based on their numeric values, then sorts the second
    'variable in descending order numerically
    spr.SortData(1,scSortAscending,scSortByNumeric, _
        2, scSortDescending, scSortByNumeric)
End Sub