Compartir a través de


Range.Value Property (Excel)

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

Name

Required/Optional

Data Type

Description

RangeValueDataType

Optional

Variant

The 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.

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

See Also

Concepts

Range Object

Range Object Members