ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Difference between .value and .value2 (https://www.excelbanter.com/excel-programming/369954-difference-between-value-value2.html)

DaveO

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.

NickHK

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" wrote in message
...
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.




Mike Fogleman

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" wrote in message
...
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.




keepITcool

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

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" wrote in message
...
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.


keepITcool

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


keepITcool

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.



All times are GMT +1. The time now is 10:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com