Value Property

Applies To

Application Object, Borders Collection, CheckBox Object, DrawingObjects Collection, DropDown Object, DropDowns Collection, ListBox Object, ListBoxes Collection, Name Object, OptionButton Object, OptionButtons Collection, PivotField Object, PivotItem Object, PivotTable Object, Range Object, ScrollBar Object, ScrollBars Collection, Spinner Object, Spinners Collection, Style Object.

Description

The meaning of the Value property depends on the object to which it is applied, as shown in the following table.

Object

Value

Application

Always returns "Microsoft Excel". Read-only.

Borders

Synonym for Borders.LineStyle.

CheckBox

Indicates check box status (xlOn, xlOff, or xlMixed).

DropDown, ListBox

Indicates the selected item in the list (the value is always between one and the number of items in the list). This method cannot be used with multi-select list boxes; use the Selected method instead.

Name

A string containing the formula that the name is defined to refer to, in A1-style notation, in the language of the macro, beginning with an equal sign. Read-only.

OptionButton

Indicates button status (one of xlOn or xlOff).

PivotField

The name of the field in the PivotTable.

PivotItem

The name of the item in the PivotTable field.


Object

Value

PivotTable

The name of the PivotTable.

Range

The value of a cell. If the cell is empty, returns the value Empty. Use the IsEmpty function to test for this case. If the Range object contains more than one cell, returns an array of values. Use the IsArray function to test for this case.

ScrollBar

The position of the scroll box.

Spinner

A value between the minimum and maximum range limit.

Style

The name of the style.


See Also

LineStyle Property, MultiSelect Property, Selected Property.

Example

This example sets the value of cell A1 on Sheet1 to 3.14159.


Worksheets("Sheet1").Range("A1").Value = 3.14159

This example loops on cells A1:D10 on Sheet1. If one of the cells has a value less than 0.001, the code replaces the value with 0 (zero).


For Each c in Worksheets("Sheet1").Range("A1:D10")
    If c.Value < .001 Then
        c.Value = 0
    End If
Next c

This example is a simple event procedure for a list box on a custom dialog box, Dialog1. The example sets the variable itemNum to the index of the selected item in the list box.


itemNum = DialogSheets("Dialog1").ListBoxes(1).Value