Home |
Search |
Today's Posts |
#14
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Oops. Didn't know you were returning the value to the worksheet.
(but you could return it as a string--yeah, I know you knew that <bg.) Myrna Larson wrote: Yes, you can, but the worksheet doesn't support it, so if/when you transfer the data back to the worksheet, digits past 15 are lost. On Tue, 15 Mar 2005 21:15:51 -0600, Dave Peterson wrote: I lost the other thread, but if you use Decimals in VBA, you can get more than 15 significant digits (I think 28). Option Explicit Sub testme() Dim myDecimal As Variant myDecimal = CDec(1) / 3 MsgBox myDecimal End Sub Myrna Larson wrote: AS you find in Help, Format returns a variant; Format$ returns a string. Since a string is what I want, there's no point in having VBA convert a string to a variant, under the hood, then me convert it from a variant to a string. IOW, it saves time. When working with strings, I always use the string version when VBA offers a choice, i.e. LEFT$, RIGHT$, MID$, LCASE$, UCASE$, STRING$, etc. Most people suggest you avoid using variants unless absolutely necessary. i.e. if the data is text, define the variable AS STRING, and use the string functions with it. As I think I mentioned (in surprise), Excel has only 15 digits of precision. A 16 digit number will be rounded to 15, with a zero added as the 16th digit. What puzzled me was that this didn't happen with the example I gave in my other post. On 14 Mar 2005 16:09:06 -0800, "Dave Unger" wrote: Hi Myrna, I found your approach to this very interesting. I haven't been doing this very long (as you've maybe discerned), hope you don't mind if I ask you a couple of (maybe stupid) questions. 1 - why Format$ instead of just Format. 2 - I can't get it to quite work for me - the spacing is correct, but the last 2 digits are always rounded, eg, I always get 111 22 333333 444 60 instead of 111 22 333333 444 55. I must be doing something wrong, but can't seem to figure out what. Thanks, Dave -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how do I remove leading spaces and leave the remianing spaces w | Excel Worksheet Functions | |||
spaces not recognized as spaces | Excel Worksheet Functions | |||
A better way to get rid of spaces | Excel Programming | |||
Help copying a range with spaces to a range without spaces | Excel Programming | |||
Spaces | Excel Programming |