Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 5. Working with Excel Objects > Editing the Values in a Range

Editing the Values in a Range

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.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial