+ Reply to Thread
Results 1 to 3 of 3

division by zero in code

Hybrid View

John2Chr division by zero in code 01-16-2013, 03:41 PM
Bishonen Re: division by zero in code 01-16-2013, 03:44 PM
John2Chr Re: division by zero in code 01-17-2013, 11:14 AM
  1. #1
    Registered User
    Join Date
    01-16-2013
    Location
    Minnesota,USA
    MS-Off Ver
    Excel 2010
    Posts
    2

    division by zero in code

    How do I make the below code display 0 if c390 is 0. Division by zero fix


    Sub Macro2()

    Dim cell As Range
    Dim icell As Single
    Dim iMultipler As Single

    iMultipler = Range("c388").Value
    For Each cell In Selection.Cells
    icell = cell.Value
    cell.Formula = "=" & icell & "*" & Range("c388").Address(, , , True) & "/" & Range("c390").Address(, , , True)
    Next

  2. #2
    Valued Forum Contributor
    Join Date
    03-17-2012
    Location
    Warsaw, Poland
    MS-Off Ver
    2007/2010
    Posts
    555

    Re: division by zero in code

    if range("C390") = 0 then
    cell = 0
    end if
    cell.Formula ...
    If you think that my answer was helpful, please click on the "Add to this user's Reputation" button.

  3. #3
    Registered User
    Join Date
    01-16-2013
    Location
    Minnesota,USA
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: division by zero in code

    where does this get inserted in the code?

+ 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