Search notes:

Excel Object Model: Application.Selection

The application.selection returns the currently selected object, for example a range or picture object.
The object type which selection refers to can be determined with typename(selection) which returns Range, Picture etc.
When the current selection changes, the worksheet event selectionChange is fired.
A range can be selected with the range.select method.

Example

sub main()

    range("b3:c5").select

  '
  ' After selecting a range, application.selection accordingly
  ' is a range. typeName(…) prints "Range".
  '
    debug.print typeName(application.selection)

  '
  ' We can now use application.selection to change
  ' the properties of the selected range
  '
    with application.selection
        .font.name      = "Courier New"
        .numberFormat   = "0.000"
        .interior.color = rgb(220,220,255)
    end with

end sub
Github repository about-MS-Office-object-model, path: /Excel/Application/selection.bas

See also

window.rangeSelection
Turn the values of the selected range into SQL insert statements.

Index