Value Property

Microsoft Excel Visual Basic

Show All

Value Property

       

Value property as it applies to the Application, CubeField, and Style objects.

For the Application object, always returns "Microsoft Excel". For the CubeField object, the name of the specified field. For the Style object, the name of the specified style. Read-only String.

expression.Value

expression   Required. An expression that returns one of the above objects.

Value property as it applies to the Borders and CustomProperty objects.

Synonym for Borders.LineStyle. Read/write Variant.

expression.Value

expression   Required. An expression that returns one of the above objects.

Value property as it applies to the ControlFormat object.

The name of specified control format. Read/write Long.

expression.Value

expression   Required. An expression that returns a ControlFormat object.

Value property as it applies to the Error and Validation objects.

True if all the validation criteria are met (that is, if the range contains valid data). Read-only Boolean.

expression.Value

expression   Required. An expression that returns one of the above objects.

Value property as it applies to the Name, PivotField, PivotFormula, PivotItem, and PivotTable objects.

For the Name object, a string containing the formula that the name is defined to refer to. The string is in A1-style notation in the language of the macro, and it begins with an equal sign. For the PivotField object, the name of the specified field in the PivotTable report. For the PivotFormula object, the name of the specified formula in the PivotTable formula. For the PivotItem object, the name of the specified item in the PivotTable field. For the PivotTable object, the name of the PivotTable report. Read/write String.

expression.Value

expression   Required. An expression that returns one of the above objects.

Value property as it applies to the Parameter object.

The parameter value. For more information, see the Parameter object. Read-only Variant.

expression.Value

expression   Required. An expression that returns a Parameter object.

Value property as it applies to the Range object.

Returns or sets the value of the specified range. Read/write Variant.

expression.Value(RangeValueDataType)

expression   Required. An expression that returns a Range object.

RangeValueDataType  Optional Variant. The range value data type. Can be a xlRangeValueDataType constant.

xlRangeValueDataType can be one of these xlRangeValueDataType constants.
xlRangeValueDefault   default If the specified Range object 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).
xlRangeValueMSPersistXML   Returns the recordset representation of the specified Range object in an XML format.
xlRangeValueXMLSpreadsheet   Returns the values, formatting, formulas and names of the specified Range object in the XML Spreadsheet format.

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

As it applies to the Range object.

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