Value2 Property

Microsoft Office Web Components Object Model

Value2 Property

       

Returns or sets a Variant representing the cell value. Read/write.

expression.Value2

expression   Required. An expression that returns a Range object.

Remarks

The only difference between this property and the Value property is that the Value2 property doesn’t use the Currency and Date data types. You can return values formatted with these data types as floating-point numbers by using the Double data type.

Example

This example illustrates the differences between the Value and the Value2 properties.

Sub Value_vs_Value2()
   Dim rngCell1
   Dim rngCell2

   ' Set a variable to the cells used in this example.
   Set rngCell1 = Spreadsheet1.ActiveSheet.Range("A1")
   Set rngCell2 = Spreadsheet1.ActiveSheet.Range("A2")

   ' Set the number formats used by the cells in this example.
   rngCell1.NumberFormat = "Currency"
   rngCell2.NumberFormat = "Short Date"

   ' Set the value of cell A1 to a currency value.
   rngCell1.Value = "$123.456789"

   ' Set the value of cell A2 to a date.
   rngCell2.Value = "9/7/1970"

	' Use the Value property to return the value of cell A1.
   MsgBox "Currency returned by the Value Property = " & _
          rngCell1.Value

   ' Use the Value2 property to return the value of cell A1.
   MsgBox "Currency returned by the Value2 Property = " & _
          rngCell1.Value2

   ' Use the Value property to return the value of cell A2.
   MsgBox "Date returned by the Value Property = " & _
          rngCell2.Value

   ' Use the Value2 property to return the value of cell A2.
   MsgBox "Date returned by the Value2 Property = " & _
          rngCell2.Value2
End Sub