+ Reply to Thread
Results 1 to 4 of 4

vba calculations returning 0

  1. #1
    Registered User
    Join Date
    01-30-2013
    Location
    canada
    MS-Off Ver
    Excel 2007
    Posts
    13

    vba calculations returning 0

    Hi I am new to VBA.

    fff = (Sin(34) / 4000) * 4000

    Worksheets("Sheet1").Cells(3, 3).Value = fff

    this is giving me a value of 0 in that cell when it should give me 0.529082686. I checked the cell properties to display more decimals, but the result is 0.00000

    when i do this calculation in an excel cell and not using vba i get the correct result. What is causing this? i am doing many calculations and they keep returning 0 in the cell

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,330

    Re: vba calculations returning 0

    Hi healing and welcome to the forum,

    Did you Dimension the variable of fff as double or is it an INTEGER?
    This seems to work for me:
    Please Login or Register  to view this content.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: vba calculations returning 0

    If fff is declared as Integer or Long, you wouldn't get the decimal value.

    This worked for me.

    Please Login or Register  to view this content.
    Or just this...
    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 02-03-2013 at 05:25 PM.

  4. #4
    Registered User
    Join Date
    01-30-2013
    Location
    canada
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: vba calculations returning 0

    thanks for the help guys, that solved it

+ 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