Results 1 to 2 of 2
  1. #1
    mkc80 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Apr 2012
    Posts
    56

    Calculating % in VBA Code For Excel

    I am trying to calculate % in Excel Sheet via VBA code as follows:


    .ActiveCell.FormulaR1C1 = "=IF((ISBLANK(RC[-2])=FALSE),IF((ISERROR(RC[-2]/RC[-1]),0,RC[-2]/RC[-1]),"""")"
    But it gives me an error.
    If the RC[-2] column is blank, the result of the % column should be blank, if not, I need to check if the denominator is 0 in order to avoid division by zero error (#DIV/0! is populated if the denominator is zero)
    Can somebody please point out where is the error.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    What is RC[-1] and RC[-2]?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. VBA Code to Import Excel Files
    By Rxp in forum Programming
    Replies: 2
    Last Post: 07-26-2012, 03:57 PM
  2. Excel code not working with Excel open
    By jgelpi16 in forum Programming
    Replies: 1
    Last Post: 07-11-2011, 12:12 PM
  3. Code for calculating employees overtime pay
    By Nixx1401 in forum Access
    Replies: 17
    Last Post: 05-05-2011, 05:13 PM
  4. Replies: 4
    Last Post: 12-16-2010, 05:29 AM
  5. Code to Update Excel from Access
    By portmancp in forum Programming
    Replies: 2
    Last Post: 03-10-2010, 03:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums