This documentation is archived and is not being maintained.

Range.Value Property

Office 2007
Returns or sets a Variant value that represents the value of the specified range.

Syntax

expression.Value(RangeValueDataType)

expression   A variable that represents a Range object.

Parameters

NameRequired/OptionalData TypeDescription
RangeValueDataTypeOptionalVariantThe range value data type. Can be a xlRangeValueDataType constant.

Remarks

When setting a range of cells with the contents of an XML spreadsheet file, only values of the first sheet in the workbook are used. You cannot set or get a discontiguous range of cells in the XML spreadsheet format.

Example

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

Visual Basic for Applications
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).

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



Show: