+ Reply to Thread
Results 1 to 6 of 6

Difference between .value and .value2

Hybrid View

  1. #1
    DaveO
    Guest

    Difference between .value and .value2

    So, looking at the HelpFile it says that the difference between .Value and
    ..Value2 is that the latter does not accept Currency or Date data types.

    With that in mind, why would you ever wish to use .Value2? To me it seems
    that it's limiting and offers no real value.

    Can anyone tell me why it'd be better to use .Value2 over .Value.

    TIA.

  2. #2
    NickHK
    Guest

    Re: Difference between .value and .value2

    Dave,
    As I understand it:
    With ActiveCell
    .Value = "1/1/2005"
    MsgBox .Value2
    End With

    you can see that the .Value would depend on the format of the locale, but
    ..Value2 gives you DateSerial so you know exactly which day is meant.
    Same thing with currency and decimal/digit grouping symbols.

    NickHK

    "DaveO" <DaveO@discussions.microsoft.com> wrote in message
    news:4C169DEB-BF74-4E9B-B72B-9D7C7768F95C@microsoft.com...
    > So, looking at the HelpFile it says that the difference between .Value and
    > .Value2 is that the latter does not accept Currency or Date data types.
    >
    > With that in mind, why would you ever wish to use .Value2? To me it seems
    > that it's limiting and offers no real value.
    >
    > Can anyone tell me why it'd be better to use .Value2 over .Value.
    >
    > TIA.




  3. #3
    keepITcool
    Guest

    Re: Difference between .value and .value2


    For writing international dates and currencies it's much easier
    to use .value2 as it avoids automatic formatting.

    Sub foo()
    Dim MyDate As Currency
    Dim MyCurr As Variant
    MyCurr = 123.45
    MyDate = Now
    [a1].Value = MyDate
    [b1].Value2 = MyDate
    [a2].Value = MyCurr
    [b2].Value2 = MyCurr

    End Sub


    --
    keepITcool
    | www.XLsupport.com | keepITcool chello nl | amsterdam


    NickHK wrote in <news:<OlexrUGvGHA.4384@TK2MSFTNGP04.phx.gbl>

    > Dave,
    > As I understand it:
    > With ActiveCell
    > .Value = "1/1/2005"
    > MsgBox .Value2
    > End With
    >
    > you can see that the .Value would depend on the format of the locale,
    > but .Value2 gives you DateSerial so you know exactly which day is
    > meant. Same thing with currency and decimal/digit grouping symbols.
    >
    > NickHK
    >
    > "DaveO" <DaveO@discussions.microsoft.com> wrote in message
    > news:4C169DEB-BF74-4E9B-B72B-9D7C7768F95C@microsoft.com...
    > > So, looking at the HelpFile it says that the difference between
    > > .Value and .Value2 is that the latter does not accept Currency or
    > > Date data types.
    > >
    > > With that in mind, why would you ever wish to use .Value2? To me it
    > > seems that it's limiting and offers no real value.
    > >
    > > Can anyone tell me why it'd be better to use .Value2 over .Value.
    > >
    > > TIA.


  4. #4
    keepITcool
    Guest

    Re: Difference between .value and .value2

    typos!

    Sub foo()
    dim MyDate as date
    dim MyCurr as currency
    MyCurr = 123.45
    MyDate = Now
    [a1].Value = MyDate
    [b1].Value2 = MyDate
    [a2].Value = MyCurr
    [b2].Value2 = MyCurr
    end sub

    --
    keepITcool
    | www.XLsupport.com | keepITcool chello nl | amsterdam


  5. #5
    Mike Fogleman
    Guest

    Re: Difference between .value and .value2

    It is a matter of overhead in dealing with those two data types which have
    variables according to locale, language, monetary systems and calendar
    systems, etc. Telling Excel it does not have to deal with these two monster
    types, it can work quicker with less resources. But it also means much
    greater diligence on your part to separate the values from the value2s. That
    is why most don't use value2. As an example I had written code for a report
    that took right at 6 minutes to run, using all .Value. It took me over 4
    hours to replace with .Value2 and still run properly. At this point the
    speed of the report was 8 seconds faster.
    There's my $.02 worth
    Mike F
    "DaveO" <DaveO@discussions.microsoft.com> wrote in message
    news:4C169DEB-BF74-4E9B-B72B-9D7C7768F95C@microsoft.com...
    > So, looking at the HelpFile it says that the difference between .Value and
    > .Value2 is that the latter does not accept Currency or Date data types.
    >
    > With that in mind, why would you ever wish to use .Value2? To me it seems
    > that it's limiting and offers no real value.
    >
    > Can anyone tell me why it'd be better to use .Value2 over .Value.
    >
    > TIA.




  6. #6
    keepITcool
    Guest

    Re: Difference between .value and .value2

    Mike,

    I disagree... maybe most americans dont use
    In international environment it can save a LOT of hassle
    just using value2 and take care of formatting separately.

    --
    keepITcool
    | www.XLsupport.com | keepITcool chello nl | amsterdam


    Mike Fogleman wrote in
    <news:<otKdnefba8_pjUbZnZ2dnUVZ_uudnZ2d@insightbb.com>

    >>SNIP That is why most don't use value2.


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1