Difference between .value and .value2

D

DaveO

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.
 
N

NickHK

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
 
M

Mike Fogleman

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
 
K

keepITcool

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
 
K

keepITcool

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
 
K

keepITcool

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top