+ Reply to Thread
Results 1 to 8 of 8

VB code to convert number to integer and 2 decimal

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    VB code to convert number to integer and 2 decimal

    Hello:

    Please refer to attached file.
    I have series of data as shown
    I need VB Code to convert Column C data to Integer and column D to 2 decimal.
    Let me know if you have any questions.
    Thanks.
    R
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: VB code to convert number to interger and 2 decimal

    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,882

    Re: VB code to convert number to interger and 2 decimal

    Do you actually need to change the value or just how it's displayed?

    If former... (though I don't recommend this as you will lose precision).
    Please Login or Register  to view this content.
    NOTE: I've set output for C to E and D to F. Change column reference if you want to overwrite original value.

    If latter...
    Please Login or Register  to view this content.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: VB code to convert number to interger and 2 decimal

    Maybe:
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  5. #5
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB code to convert number to integer and 2 decimal

    Helllo Mumps1:

    This does not truncate to "0" and "0.00"
    I need the values truncated.
    Thanks
    R

  6. #6
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: VB code to convert number to integer and 2 decimal

    IF this was for a large set of data, I would do it in an array or other speed tricks.
    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB code to convert number to integer and 2 decimal

    Hello:

    I like Ken & mehmitcik solution but thanks to all

    Riz

  8. #8
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: VB code to convert number to integer and 2 decimal

    For kicks, I did it in an array.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 05-17-2016, 11:17 AM
  2. Replies: 2
    Last Post: 11-19-2015, 09:20 AM
  3. [SOLVED] convert decimal number to time : convert 1,59 (minutes, dec) to m
    By agenda9533 in forum Excel General
    Replies: 22
    Last Post: 09-15-2013, 10:43 AM
  4. Decimal number changes to integer
    By nickjnford in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-01-2013, 06:32 AM
  5. Replies: 3
    Last Post: 11-24-2012, 05:52 AM
  6. convert number (integer) into hour:minute:seconds
    By maacmaac in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-01-2011, 08:56 AM
  7. [SOLVED] excel-enter integer number and get two decimal places
    By Jack H in forum Excel General
    Replies: 2
    Last Post: 10-16-2005, 05:05 PM

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