Results 1 to 6 of 6

Thread: Description of the Value2 property for the Range object in Excel

  1. #1
    Join Date
    Aug 2006
    Posts
    300

    Description of the Value2 property for the Range object in Excel

    Hi folks,
    I am trying to do some coding in Excel using Visual Basic Applications. I have done some basic coding in VBA, so you can consider me as rookie in VBA. I always get confused while studying about the Value2 property. This property is used for the range object in an Excel. So thought that I would get some help from you guys.!! So please provide the description of the Value2 property for the Range object in Excel Any other information related to the topic would be grateful.!!

  2. #2
    Join Date
    Apr 2008
    Posts
    2,139

    Re: Description of the Value2 property for the Range object in Excel

    I would like to explain you the concepts, so that later on you will find easy to understand this topic. Microsoft Excel includes a property Visual Basic for Applications called Value2. The Value2 property, which you can use for the Range object, is almost identical to the Value property except that the Value2 property does not use the Currency data types and date. Depending on how a cell is formatted, the two properties may return different values for the same cell. Hope that you got the basic point.

  3. #3
    Join Date
    Aug 2006
    Posts
    287

    Re: Description of the Value2 property for the Range object in Excel

    You should know that Value2 property is not available in versions prior to Excel 97. Therefore, if a cell is formatted with a number format to currency or number format date, the Value property can not return the expected value of the underlying cell. This applies to the Microsoft Office Excel 2003, and the lower versions of it. Since you have not described the version that you are using, I thought that this information would be useful for you.!!
    Dimension 1100 (FMY032J) mini-tower
    2.53ghz Intel Pentium 4
    80 gig nfts HDD
    512 RAM
    Main circuit board: Dell 0CF458
    BIOS: Dell A00
    Display: Intel(R) 82865G Graphics Controller [Display adaptor]
    Multimedia: Sound MAX Integrated Digital Audio
    Windows XP Home SP2

  4. #4
    Join Date
    Jul 2006
    Posts
    339

    Re: Description of the Value2 property for the Range object in Excel

    In the following example, the Value and Value2 properties return different results for the same object cell. To view the results, proceed as follows :
    1. Close and save open workbooks and then create a new workbook.
    2. Enter the following in Sheet1 :
      Code:
       A1: 1.23456789
          A2: Feb 3, 97
    3. Click on cell A1 and then click cell menu format. Under the number tab, click Currency in the Category list, then click OK.
    4. Click cell A2, then click on cell in the format menu.
    5. Click the number tab, click Date in the Category list and click OK.
    6. Start the Visual Basic Editor (press ALT + F11).
    7. On the Insert menu, click Module.
    8. Then you will have to enter the proper coding in module.

  5. #5
    Join Date
    May 2008
    Posts
    390

    Re: Description of the Value2 property for the Range object in Excel

    You can enter the following code in module, in the above step described by 'NIcaBoy'. The code would be :
    Code:
    Sub Value_vs_Value2()
    
             'Creates a cell value formatted as Currency
             Range("A1").Formula = "$1.23456789"
     
             'Creates a cell value formatted as a Date
             Range("A2").Formula = "2/3/1997"
    
             MsgBox "Currency returned by Value property = " & _
                Sheet1.Range("A1").Value
    
             MsgBox "Currency returned by Value2 property = " & _
                Sheet1.Range("A1").Value2
    
             MsgBox "Date returned by Value property = " & _
                Sheet1.Range("A2").Value
    
             MsgBox "Date returned by Value2 property = " & _
                Sheet1.Range("A2").Value2
    
             Range("A3").Value = Range("A1").Value
    
             MsgBox "Currency set by Value property = " & _
                 Range("A3").Value
    
             Range("A4").Value = Range("A1").Value2
    
             MsgBox "Currency set by Value2 property = " & _
                Range("A4").Value2
    
          End Sub

  6. #6
    Join Date
    May 2008
    Posts
    353

    Re: Description of the Value2 property for the Range object in Excel

    The value of underlying cell in cell A1 is 1.23456789. However, the Value property returns 1.2346. This is because Excel stores numbers in currency format integer that is multiplied by 10 000 to produce a fixed-point numbers with fifteen digits to the left of the decimal point and four digits to the right of the decimal. For cells formatted as currency, the Value2 property returns the cell value underlying real. The value of underlying cell in cell A2 is 35,464, which is the serial number, 3 Feb 97. The Value property returns a date in short date format. For cell formatted as a date, the Value2 property returns the serial number of the underlying.

Similar Threads

  1. Replies: 6
    Last Post: 13-05-2010, 12:11 PM
  2. Description of the LINEST function in Excel 2003
    By PsYcHo 1 in forum Windows Software
    Replies: 5
    Last Post: 13-03-2010, 05:47 AM
  3. Select a range of sheets in Excel VBA
    By RyanInt in forum Software Development
    Replies: 6
    Last Post: 16-01-2010, 11:47 AM
  4. Excel range finder
    By ManishS in forum Windows Software
    Replies: 2
    Last Post: 25-06-2009, 11:26 AM
  5. Run time error:'1004': Method 'Range' of object '_Global' failed
    By 2muchreality in forum Software Development
    Replies: 2
    Last Post: 11-10-2008, 02:46 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,139,250.65423 seconds with 16 queries