+ Reply to Thread
Results 1 to 6 of 6

Printing array values as integers not doubles

  1. #1
    Registered User
    Join Date
    05-31-2010
    Location
    Washington D.C.
    MS-Off Ver
    Excel 2003
    Posts
    8

    Printing array values as integers not doubles

    Hello all,

    I am creating a tool which stores weighted average values for various indicators in an array. For the purpose of storing the data and doing the calculations, I needed to Dim array as double. However, I now want to print out my my array values as integer numbers with only 2 decimal places. Problem is, that when I print it out in a message box, the values I get have over 10 decimal places (because they are stored as doubles in the array). When I tried to use an integer array instead my weighted average values turned up as zero rather than the correct number. Is there some way to convert array output to integer numbers cell by cell?

    Can someone help? Thanks so much in advance!!

    Please Login or Register  to view this content.
    Last edited by sunita; 06-04-2010 at 03:30 PM.

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Printing array values as integers not doubles

    Integers are whole numbers and don't have decimal places, so I don't really follow.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    05-31-2010
    Location
    Washington D.C.
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Printing array values as integers not doubles

    Dear Romperstomper,

    Well, I guess what I am asking then, is how to print numbers with only 2 decimal places to the screen.

    Cheers
    Sunita

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Printing array values as integers not doubles

    Use something like:
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    to round to 2DP.

  5. #5
    Registered User
    Join Date
    05-31-2010
    Location
    Washington D.C.
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Printing array values as integers not doubles

    this worked like a charm!

    just another question on formatting--- how do align this same array output in the message box so that it is all right aligned?
    is there a simple way to do this?

    thank you!!
    sunita

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Printing array values as integers not doubles

    No, not really. You would have to mess about with spaces and tabs. A userform would be easier if it's important.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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