+ Reply to Thread
Results 1 to 7 of 7

Code won't execute

  1. #1
    Forum Contributor
    Join Date
    09-08-2010
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    125

    Code won't execute

    I am trying to get the line of code below to work but it won't work with a Double variable. Can someone tell me what I am doing wrong?


    Please Login or Register  to view this content.
    Last edited by ccpsc; 10-03-2012 at 01:21 AM. Reason: Change title

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Code won't execute

    Try this instead:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    09-08-2010
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    125

    Re: Code won't execute

    Thanks that worked. I changed it to the code below which also works and better suits my needs. I don't understand how/why this works, can you explain it to me?

    Please Login or Register  to view this content.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Code won't execute

    That error means your formula has exceeded the limitations of the variable type. By expressly using the Clng() to constrain those whole numbers it seems to hold things in place properly. I can't say I fully understand it, but that's a known issue and the the known "workaround".

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Code won't execute

    ((6 - 0.05) * (1200 / 100)) / (60 * clng(60 * 24))

    This part, 60 * clng(60 * 24), generates a value of 86400 which exceeds the Integer limit of 32767
    Cheers
    Andy
    www.andypope.info

  6. #6
    Forum Contributor
    Join Date
    09-08-2010
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    125

    Re: Code won't execute

    Thanks guy's that makes sense

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Code won't execute

    I have marked this thread solved for you.
    In the future please select Thread Tools from the menu above and mark the thread as solved. Thanks.

+ 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