+ Reply to Thread
Results 1 to 9 of 9

How do you multiply a percent?

Hybrid View

arkan01d How do you multiply a percent? 05-14-2013, 10:16 AM
Norie Re: How do you multiply a... 05-14-2013, 10:40 AM
arkan01d Re: How do you multiply a... 05-14-2013, 11:03 AM
shg Re: How do you multiply a... 05-14-2013, 11:09 AM
Norie Re: How do you multiply a... 05-14-2013, 11:10 AM
arkan01d Re: How do you multiply a... 05-14-2013, 02:43 PM
Norie Re: How do you multiply a... 05-14-2013, 03:16 PM
arkan01d Re: How do you multiply a... 05-14-2013, 03:56 PM
Norie Re: How do you multiply a... 05-14-2013, 04:06 PM
  1. #1
    Registered User
    Join Date
    05-08-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    10

    How do you multiply a percent?

    I have a program for finding the short rate of a cancellation and I've run into a snag.

    Sub ShortRating()
        'for short rate
        Dim Factor As Double
        Dim ShortFactor As Double
    
        Factor =    0.988950276 
            
        Factor = 1 - Factor
        ShortFactor = Factor * 0.5
        Factor = Factor + ShortFactor
        
        Msgbox Factor
        
    End Sub
    When I run this, my Factor goes in as 0.01149 then once I multiply the ShortFactor it shows up as 5.745. How do I multiply 50%? I tried adding zeros and as you can see I tried storing the value in a variable and I tried putting quotes around it. I'm kind of at a loss. On a calculator I should be coming up with 0.0005745
    Last edited by arkan01d; 05-14-2013 at 10:57 AM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: How do you multiply a percent?

    Strange, when I run your code ShortFactor comes out as 0.494255 and Factor as 1.482765.

    If I calculate, in the debug window, ShortFactor*0.5 I get 0.005745, which is also the result I get on a calculator.

    Have you perhaps got a typo here?
    ShortFactor = Factor * 0.5
    PS Can you please use code tags, it's kind of a forum rule?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    05-08-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: How do you multiply a percent?

    Sorry for not using code tags. I'm new to the forums and new to programming in general. I cleaned up my code a little bit. I set the value of factor that comes into this sub. If I type this out on the calculator I end with a factor of 0.016574. However this program outputs 1.6574. What am I typing incorrectly here?

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How do you multiply a percent?

    The number is being displayed in scientific format (1.67...E-2).

    Try

    MsgBox Format(Factor, "0.0000%")
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: How do you multiply a percent?

    Eh, you''ve kind of totally changed the code.

    Anyway, if I run through your code Factor comes out as 1.65745860000001E-02 which is 0.0165745860000001.

    Or 1.6574 * 10-2 if you like.

  6. #6
    Registered User
    Join Date
    05-08-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: How do you multiply a percent?

    Oh ok, it's in scientific format. So how do I get it back to a normal number so that I can use it to acurately calculate a total? I'm using that factor * a premium to get the acutal amount that was due at time of cancellation. Say the total premium was $900 I multiply that by the factor to get the actual amount due. With a factor of 0.016574586 it's $14.91. With the factor in scientific format I'm getting $1,491.71. That's a big difference.

    Do I need to change the data type of Factor?

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: How do you multiply a percent?

    The number 0.01657... is the same as 1.657E-2, they are just formatted differently.

    If I try this formula in Excel.
    Formula: copy to clipboard

    =900*1.657E-2

    the result is 14.91, not 1,491.

    How are you doing the calculation?

  8. #8
    Registered User
    Join Date
    05-08-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: How do you multiply a percent?

        premiumdue = Factor * premiumpaid
    Well I just ran it again and got the right answer. There seems to be something going on after that, that's outputting the incorrect answer. Thank you very much for your help. At least I know I didn't do that part wrong

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: How do you multiply a percent?

    I think it might be the formatting that's confusing.

    Also, when you are working with very small amounts Excel can sometimes switch to scientific format.

    Try using the Format function to get the result formatted as you want it.
    MsgBox Format(premiumdue, "Currency")

+ 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