How to use Decimal data type?

  • Thread starter Thread starter Sun Tzu
  • Start date Start date
S

Sun Tzu

Excel VBA Editor Help says Decimal is a supported data type, but
defining a variable as Decimal does not work.

Dim decX as Decimal

How can I do this? Is there a reference that I need to add?

Thanks,
Wes
 
Also from VBA Help:

Note At this time the Decimal data type can only be used within a Variant, that is, you cannot declare a variable to be of type
Decimal. You can, however, create a Variant whose subtype is Decimal using the CDec function.


--
Kind regards,

Niek Otten
Microsoft MVP - Excel


| Excel VBA Editor Help says Decimal is a supported data type, but
| defining a variable as Decimal does not work.
|
| Dim decX as Decimal
|
| How can I do this? Is there a reference that I need to add?
|
| Thanks,
| Wes
|
 
I'd use:

Dim decX as variant
decx = cdec(someothervariable)
 
Hi,

Use 'Single' for 7 decimals of precision or 'Double' for 15 decimals of
precision

Mike.
 
Hi, Mike,

Unfortunately, not all decimal values convert accurately to binary
formats. That's why Decimal format exists.

Thanks,
Wes
 

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

Back
Top