+ Reply to Thread
Results 1 to 8 of 8

range.Value = a() chopping off decimals

Hybrid View

  1. #1
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    range.Value = a() chopping off decimals

    When I use this:
    myRange.Value = a()
    If a() has numbers with 3 or more decimals, only 2 get put into myRange.

    How can I get all the decimals from an array into a range?
    Last edited by foxguy; 07-01-2009 at 12:06 PM.

  2. #2
    Forum Contributor
    Join Date
    04-01-2009
    Location
    Irvine, CA
    MS-Off Ver
    Excel 2010
    Posts
    280

    Re: range.Value = a() chopping off decimals

    Are you sure it is only pasting two decimal points or is your cell formatted for two decimal points?

  3. #3
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: range.Value = a() chopping off decimals

    It's only pasting 2 decimals. I have the cells formatted for 3 decimals.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: range.Value = a() chopping off decimals

    might help if you provide a small sample file (with VBA in place) that illustrates the problem in action - I for one can't replicate... ie:

    Dim a: a = Array(10.234, 11.1)
    Range("A1").Resize(UBound(a) + 1) = Application.Transpose(a)
    works as expected

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,997

    Re: range.Value = a() chopping off decimals

    How did you declare and populate a()? If you assigned a currency formatted range to a, you could get that behaviour.
    Everyone who confuses correlation and causation ends up dead.

  6. #6
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: range.Value = a() chopping off decimals

    That's what it was. I populated the array from a range formatted currency 4 decimals.
    It bothers me that even though the array had 4 decimals in it, it only pasted 2. Seems like a bug in Excel.

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,997

    Re: range.Value = a() chopping off decimals

    Nah, it's a 'feature'...
    You should also be able to use the Value2 property to get doubles passed to the array instead.

  8. #8
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: range.Value = a() chopping off decimals

    Quote Originally Posted by romperstomper View Post
    Nah, it's a 'feature'...
    You should also be able to use the Value2 property to get doubles passed to the array instead.
    Never used Value2 before. Looks like it solves the problem, so I don't have to worry about how the range is formatted.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1