Results 1 to 4 of 4

VBA Noob multiplication isn't working with decimal

Threaded View

  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?

    Sub calctest()
    Dim number1 As Integer 
    Dim number2 As Integer
    Dim answer As Integer
    
    Sheets("Feeds and Diamters").Select
    
    number1 = Range("d2").Value
    number2 = Range("n2").Value
    
    answer = number1 * number2
    
    Range("r5") = answer
    
    End Sub
    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

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