+ Reply to Thread
Results 1 to 4 of 4

VBA Noob multiplication isn't working with decimal

  1. #1
    Registered User
    Join Date
    01-14-2009
    Location
    Great Bend, Pennsylvania
    MS-Off Ver
    Excel 2000
    Posts
    22

    VBA Noob multiplication isn't working with decimal

    I just started using VBA and WOW at the possibilities!! I have some data I am trying to calculate and decided upon researching VBA that this would be the easiest way to do what I need to.

    The code goes through no errors but D2 is .0001 and N2 is 12000 and the answer I get when I multiply the 2 through VBA is 0.000 however if I change the number in D2 to 2 then I get 24000. I tried the help menu and possibly this is because I didn't do something right with the decimal?

    Please Login or Register  to view this content.
    Again keep in mind this is my first attempt at writing my own VBA code, so feel free to add comments to better my formatting and such.

    Thanks for any help in advance
    Last edited by Dustin S.; 04-02-2009 at 10:56 AM. Reason: spell checked myself

  2. #2
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: VBA Noob multiplication isn't working with decimal

    a quick comment.
    why do you have the number1 and number2 declared as integers?
    that's why when you make it .0001 it treats it as 0.
    modytrane

  3. #3
    Registered User
    Join Date
    01-14-2009
    Location
    Great Bend, Pennsylvania
    MS-Off Ver
    Excel 2000
    Posts
    22

    Re: VBA Noob multiplication isn't working with decimal

    I was using examples I found online to help me write the code...

    I made the assumption integer meant any number.

    What should I have there?
    Last edited by Dustin S.; 04-02-2009 at 10:26 AM.

  4. #4
    Registered User
    Join Date
    01-14-2009
    Location
    Great Bend, Pennsylvania
    MS-Off Ver
    Excel 2000
    Posts
    22

    Re: VBA Noob multiplication isn't working with decimal

    Changed the Integers to Doubles and IT WORKS!!!

    Please Login or Register  to view this content.
    Any constructive criticism on the new format?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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