简体   繁体   中英

How to return value from a cell same as it is in vba?

How to return value from a cell same as it is in VBA?

For example:
A1 has "0.00000" But when I create a double and store this value in that, it stores as "0" But I want it with the same format.

Dim i as Double 
i = Range("A1").Value

Result: i = 0

You are confusing the value of a cell with the textural representation of the value.

If you want the latter then use

Dim s as String
s = Range("A1").Text

But note that a number is simply a number. The quantity of zeros after the decimal separator or the number of zeros before the number does not change the value of that number.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM