+ Reply to Thread
Results 1 to 5 of 5

Calculation issue with zero

  1. #1
    Registered User
    Join Date
    03-28-2011
    Location
    Shelbyville, TN
    MS-Off Ver
    Excel 2003
    Posts
    2

    Calculation issue with zero

    This works except when it gets to cells (x, 7) and (x, 8) and both have a zero in the cell. I get an Error '6' "Overflow" message. How can I fix?



    Dim x As Integer
    Dim Y As Integer

    x = 2
    Y = 2

    Do
    If Cells(x, 1) >= Not Empty Then
    Cells(Y, 23) = Cells(x, 7) / Cells(x, 5)
    Cells(Y, 24) = Cells(x, 7) / Cells(x, 8)
    Cells(Y, 25) = Cells(x, 8) / Cells(x, 5)

    Y = Y + 1

    End If
    x = x + 1
    Loop Until Cells(x, 1) = Empty

  2. #2
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Calculation issue with zero

    Add another conditional check.

    Please Login or Register  to view this content.

  3. #3
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Calculation issue with zero

    Quote Originally Posted by Edscuda in a private message
    Thanks for your help. This is better but I am getting a "Loop Without Do" message now.
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    03-28-2011
    Location
    Shelbyville, TN
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Calculation issue with zero

    That did it! Thank you very much for your help. As you can tell I am a novice at VBA.

  5. #5
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Calculation issue with zero

    This could be simplified even further since x and y will always be the same.

    Please Login or Register  to view this content.

+ 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