+ Reply to Thread
Results 1 to 2 of 2

Decimal number changes to integer

  1. #1
    Registered User
    Join Date
    04-01-2013
    Location
    Bicester
    MS-Off Ver
    Excel 2007
    Posts
    1

    Decimal number changes to integer

    Hi,

    I am writing a simple procedure in a Worksheet_SelectionChange sub where I need to read a number from the spreadsheet and use it in calculations but the calculations are turning out wrong and I have tracked it down to a decimal number being somehow converted to an integer. In the procedure:

    Dim VolFlow As Long
    VolFlow = Cells(10, 9)

    If I enter the number 1.4 into the spreadsheet VolFlow becomes truncated to 1 and if I enter 1.6 VolFlow becomes 2. Cells(10, 9) has no special formatting, but that shouldn't affect this should it? Any help would be gratefully received thanks!

    OK - Got it - I'm really rusty! Long is a Long int isn't it!!!

    Cheers,

    Nick
    Last edited by nickjnford; 04-01-2013 at 06:56 AM.

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Decimal number changes to integer

    Long is short for Long Integer-I reckon you want to use Double instead
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ 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