Go Back   TechArena Community > Software > Windows Software
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , ,

Sponsored Links



Description of the Value2 property for the Range object in Excel

Windows Software


Reply
 
Thread Tools Search this Thread
  #1  
Old 11-03-2010
N I C K's Avatar
Member
 
Join Date: Aug 2006
Posts: 276
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.!!
__________________
He who asks is a fool for five minutes, but he who does not ask remains a fool forever.
-Chinese Proverb
Reply With Quote
  #2  
Old 11-03-2010
chroma's Avatar
Member
 
Join Date: Apr 2008
Posts: 2,144
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.
Reply With Quote
  #3  
Old 11-03-2010
Rob Dizzle's Avatar
Member
 
Join Date: Aug 2006
Posts: 277
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
Reply With Quote
  #4  
Old 11-03-2010
Member
 
Join Date: Jul 2006
Posts: 283
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.
Reply With Quote
  #5  
Old 11-03-2010
Zenon's Avatar
Member
 
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
Reply With Quote
  #6  
Old 11-03-2010
Kirmiac's Avatar
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Software > Windows Software


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Description of the Value2 property for the Range object in Excel"
Thread Thread Starter Forum Replies Last Post
Date Range via IF THEN statement in Excel Indudep MS Office Support 3 1 Week Ago 07:48 PM
Javascript Replace function - Object doesn't support this property or method Trini Alvarado Software Development 6 13-05-2010 01:11 PM
Description of the LINEST function in Excel 2003 PsYcHo 1 Windows Software 5 13-03-2010 05:47 AM
Excel range finder ManishS Windows Software 2 25-06-2009 12:26 PM
Run time error:'1004': Method 'Range' of object '_Global' failed 2muchreality Software Development 2 11-10-2008 03:46 PM


All times are GMT +5.5. The time now is 11:02 PM.