Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Two methods are typically used to get and set the values in a range. The first way is to use the methods get_Value and set_Value. The second way is to use the property Value2. Value2 and get_Value differ in that the Value2 property returns cells that are currency or dates as a double value. Also, get_Value takes an optional parameter of type XlRangeValueDataType. If you pass XlRangeValueData.xlRangeValueDefault, you will get back an object representing the value of the cell for a single cell Range. For both Value2 and get_Value, if the Range contains multiple cells, you will get back an array of objects corresponding to the cells in the Range.
Listing 5-33 shows several examples of using Value2 including an example of passing an array of values to Value2. Setting the values of the cells in a Range all at once via an array is more efficient than making multiple calls to set each cell individually.